diff --git a/src/network-device.js b/src/network-device.js index 30fbb56..e341bd0 100644 --- a/src/network-device.js +++ b/src/network-device.js @@ -36,8 +36,8 @@ const InterfaceConfigurationSource = fromProtobufEnum(proto.InterfaceConfigurati /** * Converts a given interface IP address object with version into a dotted-decimal format. * -* @param {int32 or buffer} addr Address sent as int32 for 'v4' and as a buffer for 'v6' -* @param {string} version 'v4' or 'v6; +* @param {object} ifaceAddr +* @param {string} version 'v4' or 'v6' * @returns {string} address in dotted-decimal format */ function convertInterfaceAddress(ifaceAddr, version) { @@ -56,8 +56,8 @@ function convertInterfaceAddress(ifaceAddr, version) { /** * Converts a given IP address object with version into a dotted-decimal address string. * -* @param {int32 or buffer} addr Address sent as int32 for 'v4' and as a buffer for 'v6' -* @param {string} version 'v4' or 'v6; +* @param {object} addr addr.address sent as int32 for 'v4' and as a buffer for 'v6' +* @param {string} version 'v4' or 'v6' * @returns {string} address in dotted-decimal format */ function convertIPAddress(addr, version) { @@ -137,7 +137,7 @@ const NetworkDevice = base => class extends base { * * @param {Object} [options] Options. * @param {Number} [options.timeout] Timeout (milliseconds). - * @return {Promise} + * @return {Promise} */ async getNetworkInterfaceList({ timeout = globalOptions.requestTimeout } = {}) { const res = await this.sendRequest(Request.NETWORK_GET_INTERFACE_LIST, null, { timeout }); diff --git a/src/network-device.test.js b/src/network-device.test.js index 49af383..c74e03f 100644 --- a/src/network-device.test.js +++ b/src/network-device.test.js @@ -8,7 +8,6 @@ const { getDevices } = proxyquire('../src/device-base', { }); describe('NetworkDevice', () => { - // const exampleSerialNumber = 'P046AF1450000FC'; beforeEach(async () => { const usbDevs = [];fakeUsb.addDevice({ vendorId: 0xaaaa, productId: 0xaaaa }); usbDevs.push(fakeUsb.addP2()); @@ -31,6 +30,17 @@ describe('NetworkDevice', () => { }); describe('getNetworkInfo', () => { + let dev; + beforeEach(async () => { + const devs = await getDevices(); + dev = setDevicePrototype(devs[0]); + await dev.open(); + }); + + afterEach(async () => { + await dev.close(); + }); + it('parses the result', async () => { const input = { 'index': 4, @@ -92,22 +102,14 @@ describe('NetworkDevice', () => { 'source': 'UNKNOWN' } }; - const devs = await getDevices(); - const dev = setDevicePrototype(devs[0]); - await dev.open(); sinon.stub(dev, 'sendRequest').resolves({ interface: input }); const res = await dev.getNetworkInterface({ index: 4 }); expect(res).to.eql(expectedOutput); - - await dev.close(); }); it('returns an error if the interface is invalid', async () => { - const devs = await getDevices(); - const dev = setDevicePrototype(devs[0]); - await dev.open(); sinon.stub(dev, 'sendRequest').resolves({}); let error; @@ -118,8 +120,6 @@ describe('NetworkDevice', () => { } expect(error).to.be.an.instanceOf(NotFoundError); - - await dev.close(); }); }); });