Created
February 12, 2016 14:45
-
-
Save eriktrom/62577d6b13f3fc857b01 to your computer and use it in GitHub Desktop.
Revisions
-
eriktrom created this gist
Feb 12, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,78 @@ /* * portfinder-test.js: Tests for the `portfinder` module. * * (C) 2011, Charlie Robbins * */ var vows = require('vows'), assert = require('assert'), portfinder = require('../lib/portfinder'), testHelper = require('./helper'); portfinder.basePort = 32768; var servers = []; vows.describe('portfinder').addBatch({ "When using portfinder module": { "with 5 existing servers": { topic: function () { testHelper(servers, this.callback); }, "the getPort() method": { topic: function () { portfinder.getPort(this.callback); }, "should respond with the first free port (32773)": function (err, port) { assert.isTrue(!err); assert.equal(port, 32773); } } } } }).addBatch({ "When using portfinder module": { "with 5 existing servers": { topic: function () { servers.forEach(function (server) { server.close(); }); servers = []; testHelper(servers, this.callback); }, "the getPort() method with host option set to localhost": { topic: function () { portfinder.getPort({ host: 'localhost' }, this.callback); }, "should respond with the first free port (32773)": function (err, port) { assert.isTrue(!err); assert.equal(port, 32773); } } } } }).addBatch({ "When using portfinder module": { "with no existing servers": { topic: function () { servers.forEach(function (server) { server.close(); }); return null; }, "the getPort() method": { topic: function () { portfinder.getPort(this.callback); }, "should respond with the first free port (32768)": function (err, port) { assert.isTrue(!err); assert.equal(port, 32768); } } } } }).export(module);