-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiot-loader.test.js
32 lines (27 loc) · 1.94 KB
/
iot-loader.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const fs = require('fs');
const iotLoader = require('./iot-loader');
test('load', () => {
const loxoneStructureFile = JSON.parse(fs.readFileSync('LoxAPP3-example.json', 'utf-8'));
const structure = iotLoader.loadLoxoneStructure(loxoneStructureFile);
expect(Object.values(structure.controls).length).toBe(8);
expect(Object.values(structure.controls).filter(c => c.type === 'LightController').length).toBe(3);
expect(Object.values(structure.controls).filter(c => c.type === 'Dimmer').length).toBe(3);
expect(Object.values(structure.controls).filter(c => c.type === 'Switch' && c.parent).length).toBe(1);
const things = iotLoader.createThings(structure);
expect(things.length).toBe(4);
expect(things[0].thingName).toBe('miniserver:chloe_bed:dimmer:downlights');
expect(things[0].attributePayload.attributes.loxoneControlId).toBe('0fe3e552-0153-6032-ffff95eca2fd64fa:AI1');
expect(things[0].attributePayload.attributes.manufacturerName).toBe('loxone');
expect(things[0].attributePayload.attributes.friendlyName).toBe('chloe_bed_downlights');
expect(things[0].attributePayload.attributes.name).toBe('downlights');
expect(things[0].attributePayload.attributes.room).toBe('chloe_bed');
expect(things[0].attributePayload.attributes.capabilities).toBe('brightness,powerState');
expect(things[2].thingName).toBe('miniserver:master_ensuite:switch:mirror_light');
expect(things[2].attributePayload.attributes.loxoneControlId).toBe('0ec59fd7-0288-a9e3-ffff95eca2fd64fa:AI2');
expect(things[2].attributePayload.attributes.manufacturerName).toBe('loxone');
expect(things[2].attributePayload.attributes.friendlyName).toBe('master_ensuite_mirror_light');
expect(things[2].attributePayload.attributes.name).toBe('mirror_light');
expect(things[2].attributePayload.attributes.room).toBe('master_ensuite');
expect(things[2].attributePayload.attributes.capabilities).toBe('powerState');
});