35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
|
|
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||
|
|
import { createKnxDiscoveryDescriptor } from '../../ts/integrations/knx/index.js';
|
||
|
|
|
||
|
|
tap.test('matches KNXnet/IP gateway descriptors', async () => {
|
||
|
|
const descriptor = createKnxDiscoveryDescriptor();
|
||
|
|
const matcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'knx-gateway-descriptor-match');
|
||
|
|
const result = await matcher!.matches({
|
||
|
|
ip_addr: '192.168.1.50',
|
||
|
|
port: 3671,
|
||
|
|
name: 'MDT SCN-IP000.03',
|
||
|
|
individual_address: '1.1.1',
|
||
|
|
supports_tunnelling: true,
|
||
|
|
supports_tunnelling_tcp: true,
|
||
|
|
supports_routing: true,
|
||
|
|
}, {});
|
||
|
|
expect(result.matched).toBeTrue();
|
||
|
|
expect(result.candidate?.integrationDomain).toEqual('knx');
|
||
|
|
expect(result.candidate?.metadata?.connectionType).toEqual('tunneling_tcp');
|
||
|
|
});
|
||
|
|
|
||
|
|
tap.test('matches manual KNX/IP entries', async () => {
|
||
|
|
const descriptor = createKnxDiscoveryDescriptor();
|
||
|
|
const matcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'knx-manual-match');
|
||
|
|
const result = await matcher!.matches({
|
||
|
|
host: '192.168.1.51',
|
||
|
|
connectionType: 'tunneling',
|
||
|
|
individualAddress: '0.0.240',
|
||
|
|
}, {});
|
||
|
|
expect(result.matched).toBeTrue();
|
||
|
|
expect(result.candidate?.host).toEqual('192.168.1.51');
|
||
|
|
expect(result.candidate?.port).toEqual(3671);
|
||
|
|
});
|
||
|
|
|
||
|
|
export default tap.start();
|