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
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
const path = require('path');
|
|
const delay = require('delay');
|
|
|
|
const {
|
|
startNockRecording,
|
|
storeNockRecordings,
|
|
playbackNockTapes,
|
|
} = require('./nock-helpers');
|
|
|
|
// Change to 'record' or 'play' to use nock on tests
|
|
// Set to false to run live against eWeLink servers
|
|
const nockAction = false;
|
|
|
|
// These files needs a cooldown delay between tests
|
|
const testsToDelay = [
|
|
'env-node.spec.js',
|
|
'env-serverless.spec.js',
|
|
'device-control.spec.js',
|
|
'invalid-credentials.spec.js',
|
|
'power-usage.spec.js',
|
|
'temperature-humidity.spec.js',
|
|
'valid-credentials.spec.js',
|
|
];
|
|
|
|
const getTapFilename = global => {
|
|
const { testPath } = global.jasmine;
|
|
const tapeFile = path.basename(testPath, '.js');
|
|
return `./test/_setup/tapes/${tapeFile}.json`;
|
|
};
|
|
|
|
global.beforeAll(() => {
|
|
if (nockAction === 'record') {
|
|
startNockRecording();
|
|
}
|
|
|
|
if (nockAction === 'play') {
|
|
const tapeFile = getTapFilename(global);
|
|
playbackNockTapes(tapeFile);
|
|
}
|
|
});
|
|
|
|
global.afterAll(() => {
|
|
if (nockAction === 'record') {
|
|
const tapeFile = getTapFilename(global);
|
|
storeNockRecordings(tapeFile);
|
|
}
|
|
});
|
|
|
|
global.beforeEach(async () => {
|
|
if (nockAction === 'play') {
|
|
return;
|
|
}
|
|
|
|
const { testPath } = global.jasmine;
|
|
const testFile = path.basename(testPath);
|
|
|
|
if (testsToDelay.includes(testFile)) {
|
|
await delay(1000);
|
|
}
|
|
});
|