Skip to content

Commit

Permalink
more tests for different argument signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
laggingreflex committed Nov 19, 2016
1 parent c1275d1 commit da1ce58
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ test('checkPortStatus - taken', t => {
})
})

test('checkPortStatus - taken (without host)', t => {
t.plan(2)

portScanner.checkPortStatus(3000, (error, port) => {
t.is(error, null)
t.is(port, 'open')
})
})

test('checkPortStatus - free', t => {
t.plan(2)

Expand All @@ -34,6 +43,15 @@ test('checkPortStatus - free', t => {
})
})

test('checkPortStatus - free (without host)', t => {
t.plan(2)

portScanner.checkPortStatus(3001, (error, port) => {
t.is(error, null)
t.is(port, 'closed')
})
})

/* findPortInUse */

test('findPortInUse - taken port in range', t => {
Expand All @@ -45,6 +63,33 @@ test('findPortInUse - taken port in range', t => {
})
})

test('findPortInUse - taken port in range (without host)', t => {
t.plan(2)

portScanner.findAPortInUse(3000, 3010, (error, port) => {
t.is(error, null)
t.is(port, 3000)
})
})

test('findPortInUse - taken port in range (without endPort)', t => {
t.plan(2)

portScanner.findAPortInUse(3000, '127.0.0.1', (error, port) => {
t.is(error, null)
t.is(port, 3000)
})
})

test('findPortInUse - taken port in range (without endPort and host) ', t => {
t.plan(2)

portScanner.findAPortInUse(3000, (error, port) => {
t.is(error, null)
t.is(port, 3000)
})
})

test('findPortInUse - taken port in range - ports as array', t => {
t.plan(2)

Expand All @@ -54,6 +99,15 @@ test('findPortInUse - taken port in range - ports as array', t => {
})
})

test('findPortInUse - taken port in range - ports as array (without host)', t => {
t.plan(2)

portScanner.findAPortInUse([2999, 3000, 3001], (error, port) => {
t.is(error, null)
t.is(port, 2999)
})
})

test('findPortInUse - all ports in range free', t => {
t.plan(2)

Expand All @@ -72,6 +126,15 @@ test('findPortInUse - all ports in range free - ports as array', t => {
})
})

test('findPortInUse - all ports in range free - ports as array (without host)', t => {
t.plan(2)

portScanner.findAPortInUse([3001, 3005, 3008], (error, port) => {
t.is(error, null)
t.false(port)
})
})

/* findPortNotInUse */

test('findAPortNotInUse - start from free port', t => {
Expand Down

0 comments on commit da1ce58

Please sign in to comment.