test(Philips Hue Node): Add test coverage (no-changelog) (#12223)

This commit is contained in:
Jon
2024-12-16 11:00:20 +00:00
committed by GitHub
parent 1fc9c59a57
commit de75c7b529
4 changed files with 392 additions and 0 deletions

View 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));
}
});
});