Skip to content

Commit

Permalink
updates tests and works towards #17
Browse files Browse the repository at this point in the history
  • Loading branch information
sgnl committed Apr 25, 2018
1 parent ff338bd commit a9e7aff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@

'use strict';

module.exports = require('./lib/discovery');
const Discovery = require('./lib/discovery');
const Device = require('./lib/device');

function Nodeku(timeout) {
return Discovery(timeout);
}

Nodeku.Discovery = Discovery;
Nodeku.Device = Device;

module.exports = Nodeku;
16 changes: 15 additions & 1 deletion test/nodeku.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require('superagent-mock')(req, ReqMockConfig, utils.logger);
const device = proxyquire('../lib/device', {
got: req
});
const Nodeku = proxyquire('../lib/discovery', {
const Nodeku = proxyquire('../index', {
'node-ssdp': ssdpMock,
'./device': device
});
Expand All @@ -39,6 +39,20 @@ test('Nodeku', t => {
t.is(typeof Nodeku, 'function', 'is ready');
});

test('Nodeku.Device exists', t => {
t.true(Nodeku.hasOwnProperty('Device'), 'exists');
});

test('Nodeku.Discovery exists', t => {
t.true(Nodeku.hasOwnProperty('Discovery'), 'exists');
});

wrapper('-method: .ip()', (t, device) => {
t.true(device.hasOwnProperty('ip'), 'exists');
t.is(typeof device.ip, 'function', 'is a function');
t.deepEqual(device.ip(), '192.168.1.17:8060', 'ip address retreived');
});

wrapper('-method: .ip()', (t, device) => {
t.true(device.hasOwnProperty('ip'), 'exists');
t.is(typeof device.ip, 'function', 'is a function');
Expand Down

0 comments on commit a9e7aff

Please sign in to comment.