Add TypeScript integrations package
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import { createHueDiscoveryDescriptor } from '../../ts/integrations/hue/index.js';
|
||||
|
||||
tap.test('matches Hue mDNS records', async () => {
|
||||
const descriptor = createHueDiscoveryDescriptor();
|
||||
const matcher = descriptor.getMatchers()[0];
|
||||
const result = await matcher.matches({
|
||||
host: 'hue.local',
|
||||
port: 443,
|
||||
txt: {
|
||||
bridgeid: '001788fffe123456',
|
||||
},
|
||||
}, {});
|
||||
expect(result.matched).toBeTrue();
|
||||
expect(result.normalizedDeviceId).toEqual('001788fffe123456');
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
@@ -0,0 +1,20 @@
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import { HueMapper } from '../../ts/integrations/hue/index.js';
|
||||
|
||||
tap.test('maps Hue lights to canonical devices and entities', async () => {
|
||||
const resources = {
|
||||
devices: [],
|
||||
lights: [
|
||||
{
|
||||
id: 'light-1',
|
||||
metadata: { name: 'Kitchen Ceiling' },
|
||||
on: { on: true },
|
||||
dimming: { brightness: 80 },
|
||||
},
|
||||
],
|
||||
};
|
||||
expect(HueMapper.toDevices(resources).length).toEqual(1);
|
||||
expect(HueMapper.toEntities(resources)[0].id).toEqual('light.kitchen_ceiling');
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user