import { expect, tap } from '@git.zone/tstest/tapbundle';
import { createZhaDiscoveryDescriptor } from '../../ts/integrations/zha/index.js';

tap.test('matches known ZHA USB coordinator records', async () => {
  const descriptor = createZhaDiscoveryDescriptor();
  const matcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'zha-usb-match');
  const result = await matcher!.matches({
    vid: '10C4',
    pid: 'EA60',
    manufacturer: 'SONOFF',
    description: 'SONOFF Zigbee 3.0 USB Dongle Plus',
    path: '/dev/ttyUSB0',
  }, {});
  expect(result.matched).toBeTrue();
  expect(result.candidate?.integrationDomain).toEqual('zha');
  expect(result.candidate?.metadata?.radioPath).toEqual('/dev/ttyUSB0');
});

export default tap.start();
