33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
|
|
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||
|
|
import { createMpdDiscoveryDescriptor } from '../../ts/integrations/mpd/index.js';
|
||
|
|
|
||
|
|
tap.test('matches MPD mDNS records', async () => {
|
||
|
|
const descriptor = createMpdDiscoveryDescriptor();
|
||
|
|
const matcher = descriptor.getMatchers()[0];
|
||
|
|
const result = await matcher.matches({
|
||
|
|
name: 'Living Room MPD',
|
||
|
|
type: '_mpd._tcp.local.',
|
||
|
|
host: 'mpd.local',
|
||
|
|
port: 6600,
|
||
|
|
}, {});
|
||
|
|
expect(result.matched).toBeTrue();
|
||
|
|
expect(result.candidate?.integrationDomain).toEqual('mpd');
|
||
|
|
expect(result.candidate?.port).toEqual(6600);
|
||
|
|
expect(result.metadata?.mdnsType).toEqual('_mpd._tcp');
|
||
|
|
});
|
||
|
|
|
||
|
|
tap.test('matches and validates manual MPD entries', async () => {
|
||
|
|
const descriptor = createMpdDiscoveryDescriptor();
|
||
|
|
const matcher = descriptor.getMatchers()[1];
|
||
|
|
const result = await matcher.matches({ host: '192.168.1.50', name: 'Kitchen MPD' }, {});
|
||
|
|
expect(result.matched).toBeTrue();
|
||
|
|
expect(result.candidate?.port).toEqual(6600);
|
||
|
|
|
||
|
|
const validator = descriptor.getValidators()[0];
|
||
|
|
const validation = await validator.validate(result.candidate!, {});
|
||
|
|
expect(validation.matched).toBeTrue();
|
||
|
|
expect(validation.normalizedDeviceId).toEqual('192.168.1.50:6600');
|
||
|
|
});
|
||
|
|
|
||
|
|
export default tap.start();
|