mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 03:12:15 +00:00
test(Philips Hue Node): Add test coverage (no-changelog) (#12223)
This commit is contained in:
41
packages/nodes-base/nodes/PhilipsHue/test/workflow.test.ts
Normal file
41
packages/nodes-base/nodes/PhilipsHue/test/workflow.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import nock from 'nock';
|
||||
|
||||
import {
|
||||
deleteLightResponse,
|
||||
getLightsResponse,
|
||||
getConfigResponse,
|
||||
updateLightResponse,
|
||||
} from './apiResponses';
|
||||
import {
|
||||
setup,
|
||||
equalityTest,
|
||||
workflowToTests,
|
||||
getWorkflowFilenames,
|
||||
} from '../../../test/nodes/Helpers';
|
||||
|
||||
describe('PhilipsHue', () => {
|
||||
describe('Run workflow', () => {
|
||||
const workflows = getWorkflowFilenames(__dirname);
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
|
||||
const mock = nock('https://api.meethue.com/route');
|
||||
mock.persist().get('/api/0/config').reply(200, getConfigResponse);
|
||||
mock.get('/api/pAtwdCV8NZId25Gk/lights').reply(200, getLightsResponse);
|
||||
mock.put('/api/pAtwdCV8NZId25Gk/lights/1/state').reply(200, updateLightResponse);
|
||||
mock.delete('/api/pAtwdCV8NZId25Gk/lights/1').reply(200, deleteLightResponse);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
});
|
||||
|
||||
const nodeTypes = setup(tests);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user