Skip to content

Commit

Permalink
change
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Jan 26, 2024
1 parent b8f53c0 commit 982ae3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/network-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 39 in src/network-device.js

View workflow job for this annotation

GitHub Actions / Test (Node.js v12)

Trailing spaces not allowed

Check failure on line 39 in src/network-device.js

View workflow job for this annotation

GitHub Actions / Test (Node.js v14)

Trailing spaces not allowed

Check failure on line 39 in src/network-device.js

View workflow job for this annotation

GitHub Actions / Test (Node.js v16)

Trailing spaces not allowed
* @param {string} version 'v4' or 'v6'
* @returns {string} address in dotted-decimal format
*/
function convertInterfaceAddress(ifaceAddr, version) {
Expand All @@ -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) {
Expand Down Expand Up @@ -137,7 +137,7 @@ const NetworkDevice = base => class extends base {
*
* @param {Object} [options] Options.
* @param {Number} [options.timeout] Timeout (milliseconds).
* @return {Promise<String>}
* @return {Promise<Object>}
*/
async getNetworkInterfaceList({ timeout = globalOptions.requestTimeout } = {}) {
const res = await this.sendRequest(Request.NETWORK_GET_INTERFACE_LIST, null, { timeout });
Expand Down
22 changes: 11 additions & 11 deletions src/network-device.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -118,8 +120,6 @@ describe('NetworkDevice', () => {
}

expect(error).to.be.an.instanceOf(NotFoundError);

await dev.close();
});
});
});

0 comments on commit 982ae3c

Please sign in to comment.