mirror of
https://github.com/skydiver/ewelink-api.git
synced 2025-12-21 21:33:11 +01:00
* set APP_ID and APP_SECRET from main class * add APP_ID and APP_SECRET as class constructor parameters * updated test case * updated test case * added new test case * docs updated * Release v3.1.0 - "setWSDevicePowerState" (#96) * new mixing to control devices using websocket * switch status on single channel devices * working on deviceControl mixin * better error handling * working on fix for shared devices * refactor/cleanup * added helper function * added docs for new method * return device new status * added test cases * properly close websocket connection and clean used properties * added test cases * error detection enhancements * added test cases * error detection enhancements * added new test file to jest setup * method renamed * fix for closing websocket connection * new getWSDevicePowerState method * added test cases * re-arrange tests * added new test cases * extract helpers methods * added test case * close WebSocket connection on auth error * updated docs * updated dependencies * fix for "forbidden" error * updated dependencies
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
const { APP_SECRET } = require('../src/data/constants');
|
|
const ewelinkHelpers = require('../src/helpers/ewelink');
|
|
|
|
describe('check eWeLink helpers', () => {
|
|
test('make authorization sign should return right string', async () => {
|
|
const auth = ewelinkHelpers.makeAuthorizationSign(APP_SECRET, {
|
|
data: 'string',
|
|
});
|
|
expect(auth.length).toBe(44);
|
|
expect(auth).toBe('7Aaa/8EuRScACNrZTATW2WKIY7lcRnjgWHTiBl8G0TQ=');
|
|
});
|
|
|
|
test('getDeviceChannelCount method should return right value', async () => {
|
|
const deviceA = ewelinkHelpers.getDeviceChannelCount(8);
|
|
expect(typeof deviceA).toBe('number');
|
|
expect(deviceA).toBe(3);
|
|
const deviceB = ewelinkHelpers.getDeviceChannelCount(31);
|
|
expect(typeof deviceB).toBe('number');
|
|
expect(deviceB).toBe(4);
|
|
const deviceC = ewelinkHelpers.getDeviceChannelCount(29);
|
|
expect(typeof deviceC).toBe('number');
|
|
expect(deviceC).toBe(2);
|
|
const deviceD = ewelinkHelpers.getDeviceChannelCount(27);
|
|
expect(typeof deviceD).toBe('number');
|
|
expect(deviceD).toBe(1);
|
|
const unknownDevice = ewelinkHelpers.getDeviceChannelCount(5000);
|
|
expect(typeof unknownDevice).toBe('number');
|
|
expect(unknownDevice).toBe(0);
|
|
});
|
|
});
|