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

tap.test('matches Sonos SSDP ZonePlayer records', async () => {
  const descriptor = createSonosDiscoveryDescriptor();
  const matcher = descriptor.getMatchers()[0];
  const result = await matcher.matches({
    st: 'urn:schemas-upnp-org:device:ZonePlayer:1',
    usn: 'uuid:RINCON_000E58ABCDEF01400::urn:schemas-upnp-org:device:ZonePlayer:1',
    location: 'http://192.168.1.55:1400/xml/device_description.xml',
  }, {});
  expect(result.matched).toBeTrue();
  expect(result.candidate?.host).toEqual('192.168.1.55');
  expect(result.normalizedDeviceId).toEqual('RINCON_000E58ABCDEF01400');
});

export default tap.start();
