42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
|
|
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||
|
|
import { createArcamFmjDiscoveryDescriptor } from '../../ts/integrations/arcam_fmj/index.js';
|
||
|
|
|
||
|
|
tap.test('matches Arcam FMJ SSDP media renderer records', async () => {
|
||
|
|
const descriptor = createArcamFmjDiscoveryDescriptor();
|
||
|
|
const matcher = descriptor.getMatchers()[0];
|
||
|
|
const result = await matcher.matches({
|
||
|
|
st: 'urn:schemas-upnp-org:device:MediaRenderer:1',
|
||
|
|
usn: 'uuid:2f402f80-da50-11e1-9b23-001788abcdef::urn:schemas-upnp-org:device:MediaRenderer:1',
|
||
|
|
location: 'http://192.168.1.60:8080/dd.xml',
|
||
|
|
upnp: {
|
||
|
|
manufacturer: 'ARCAM',
|
||
|
|
modelName: 'AVR20',
|
||
|
|
friendlyName: 'Living Room Arcam',
|
||
|
|
deviceType: 'urn:schemas-upnp-org:device:MediaRenderer:1',
|
||
|
|
UDN: 'uuid:2f402f80-da50-11e1-9b23-001788abcdef',
|
||
|
|
},
|
||
|
|
}, {});
|
||
|
|
|
||
|
|
expect(result.matched).toBeTrue();
|
||
|
|
expect(result.candidate?.integrationDomain).toEqual('arcam_fmj');
|
||
|
|
expect(result.candidate?.host).toEqual('192.168.1.60');
|
||
|
|
expect(result.candidate?.port).toEqual(50000);
|
||
|
|
expect(result.normalizedDeviceId).toEqual('001788abcdef');
|
||
|
|
});
|
||
|
|
|
||
|
|
tap.test('matches and validates manual Arcam FMJ entries', async () => {
|
||
|
|
const descriptor = createArcamFmjDiscoveryDescriptor();
|
||
|
|
const matcher = descriptor.getMatchers()[1];
|
||
|
|
const result = await matcher.matches({ host: '192.168.1.61', name: 'Cinema Arcam', model: 'AVR850' }, {});
|
||
|
|
expect(result.matched).toBeTrue();
|
||
|
|
expect(result.candidate?.port).toEqual(50000);
|
||
|
|
|
||
|
|
const validator = descriptor.getValidators()[0];
|
||
|
|
const validation = await validator.validate(result.candidate!, {});
|
||
|
|
expect(validation.matched).toBeTrue();
|
||
|
|
expect(validation.confidence).toEqual('high');
|
||
|
|
expect(validation.normalizedDeviceId).toEqual('192.168.1.61:50000');
|
||
|
|
});
|
||
|
|
|
||
|
|
export default tap.start();
|