41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
|
import { createSqueezeboxDiscoveryDescriptor } from '../../ts/integrations/squeezebox/index.js';
|
|
|
|
tap.test('matches LMS mDNS advertisements', async () => {
|
|
const descriptor = createSqueezeboxDiscoveryDescriptor();
|
|
const matcher = descriptor.getMatchers()[0];
|
|
const result = await matcher.matches({
|
|
name: 'Home LMS._squeezebox-jsonrpc._tcp.local.',
|
|
type: '_squeezebox-jsonrpc._tcp.local.',
|
|
host: 'home-lms.local',
|
|
port: 9000,
|
|
txt: { uuid: 'server-uuid-1', name: 'Home LMS' },
|
|
}, {});
|
|
|
|
expect(result.matched).toBeTrue();
|
|
expect(result.confidence).toEqual('certain');
|
|
expect(result.normalizedDeviceId).toEqual('server-uuid-1');
|
|
expect(result.candidate?.host).toEqual('home-lms.local');
|
|
expect(result.candidate?.port).toEqual(9000);
|
|
});
|
|
|
|
tap.test('matches DHCP player hints and manual LMS candidates', async () => {
|
|
const descriptor = createSqueezeboxDiscoveryDescriptor();
|
|
const dhcp = await descriptor.getMatchers()[1].matches({
|
|
hostname: 'squeezebox-kitchen',
|
|
macaddress: '00:04:20:AA:BB:02',
|
|
ipAddress: '192.168.1.51',
|
|
}, {});
|
|
expect(dhcp.matched).toBeTrue();
|
|
expect(dhcp.candidate?.metadata?.playerDiscovery).toBeTrue();
|
|
|
|
const manual = await descriptor.getMatchers()[2].matches({ host: '192.168.1.40', name: 'Manual LMS' }, {});
|
|
expect(manual.matched).toBeTrue();
|
|
expect(manual.candidate?.port).toEqual(9000);
|
|
|
|
const validation = await descriptor.getValidators()[0].validate(manual.candidate!, {});
|
|
expect(validation.matched).toBeTrue();
|
|
});
|
|
|
|
export default tap.start();
|