Skip to content

Commit

Permalink
Tests from "Add support for checking array of ports instead of range"
Browse files Browse the repository at this point in the history
  • Loading branch information
elmccd authored and laggingreflex committed Nov 18, 2016
1 parent 9fdbdc3 commit 2ed556b
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ test('findPortInUse - taken port in range', t => {
t.is(port, 3000);
});
});

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

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

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

Expand All @@ -58,6 +67,15 @@ test('findPortInUse - all ports in range free', t => {
});
});

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

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


/* findPortNotInUse */

Expand All @@ -66,7 +84,7 @@ test('findAPortNotInUse - start from free port', t => {

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

Expand All @@ -75,7 +93,7 @@ test('findAPortNotInUse - start from taken port', t => {

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

Expand All @@ -87,3 +105,12 @@ test('findAPortNotInUse - all ports in range taken', t => {
t.false(port);
});
});

test('findAPortNotInUse - with array as parameter', t => {
t.plan(2);

portScanner.findAPortNotInUse([3000, 3002, 2999], '127.0.0.1', (error, port) => {
t.is(error, null);
t.is(port, 3002);
});
});

0 comments on commit 2ed556b

Please sign in to comment.