Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Merge 0cf0dd9 into 25bd701
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-soral committed Aug 17, 2017
2 parents 25bd701 + 0cf0dd9 commit c846cdc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.findExternalInterface = function findExternalInterface (options) {
var name = options.name;

if (name) {
return findInAddresses(networkInterfaces[name]) ? name : null;
return (networkInterfaces[name]) ? (findInAddresses(networkInterfaces[name]) ? name : null) : null;
}

return Object.keys(networkInterfaces)
Expand Down
13 changes: 13 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ describe('findExternalInterface()', function () {
expect(findExternalInterface({name: 'en14'})).to.be.null;
});
});

describe('and there is no matching interface', function () {
beforeEach(function () {
var interfaces = Object.assign({}, allInterfaces);
interfaces.en14 = interfaces.en13;
sandbox.stub(os, 'networkInterfaces')
.returns(interfaces);
});

it('should return null', function () {
expect(findExternalInterface({name: 'en15'})).to.be.null;
});
});
});

describe('when "name" option is an empty string', function () {
Expand Down

0 comments on commit c846cdc

Please sign in to comment.