18 lines
781 B
TypeScript
18 lines
781 B
TypeScript
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
|
import { createMqttDiscoveryDescriptor } from '../../ts/integrations/mqtt/index.js';
|
|
|
|
tap.test('matches Home Assistant MQTT discovery config topics', async () => {
|
|
const descriptor = createMqttDiscoveryDescriptor();
|
|
const matcher = descriptor.getMatchers()[1];
|
|
const result = await matcher.matches({
|
|
topic: 'homeassistant/sensor/kitchen/temperature/config',
|
|
payload: '{"name":"Kitchen temperature","state_topic":"kitchen/temperature"}',
|
|
}, {});
|
|
expect(result.matched).toBeTrue();
|
|
expect(result.candidate?.metadata?.component).toEqual('sensor');
|
|
expect(result.candidate?.metadata?.nodeId).toEqual('kitchen');
|
|
expect(result.normalizedDeviceId).toEqual('temperature');
|
|
});
|
|
|
|
export default tap.start();
|