Skip to content

Commit

Permalink
tests - ports as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
laggingreflex committed Nov 22, 2016
1 parent f85e493 commit 69c648c
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,58 @@ test('findAPortNotInUse - all ports in range taken', t => {
t.false(port);
});
});

test('checkPortStatus - taken (port as a string)', t => {
t.plan(2)

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

test('checkPortStatus - free (port as a string)', t => {
t.plan(2)

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

test('findPortInUse - taken port in range (startPort as a string)', t => {
t.plan(2)

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

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

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

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

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

// test('findAPortNotInUse - start from free port (startPort as a string)', t => {
// t.plan(2);

// portScanner.findAPortNotInUse('3001', 3010, '127.0.0.1', (error, port) => {
// t.is(error, null);
// t.true(port !== '3001');
// });
// });

0 comments on commit 69c648c

Please sign in to comment.