57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
|
|
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||
|
|
import { DlnaDmrMapper } from '../../ts/integrations/dlna_dmr/index.js';
|
||
|
|
import type { IDlnaDmrSnapshot } from '../../ts/integrations/dlna_dmr/index.js';
|
||
|
|
|
||
|
|
tap.test('maps DLNA renderer snapshots to canonical devices and entities', async () => {
|
||
|
|
const snapshot: IDlnaDmrSnapshot = {
|
||
|
|
device: {
|
||
|
|
location: 'http://192.168.1.50:8000/description.xml',
|
||
|
|
udn: 'uuid:renderer-1',
|
||
|
|
deviceType: 'urn:schemas-upnp-org:device:MediaRenderer:1',
|
||
|
|
friendlyName: 'Living Room Renderer',
|
||
|
|
manufacturer: 'Example',
|
||
|
|
modelName: 'DMR 1',
|
||
|
|
services: {},
|
||
|
|
},
|
||
|
|
state: {
|
||
|
|
online: true,
|
||
|
|
transport: {
|
||
|
|
currentTransportState: 'PLAYING',
|
||
|
|
currentTransportActions: ['Play', 'Pause', 'Stop'],
|
||
|
|
},
|
||
|
|
rendering: {
|
||
|
|
volume: 42,
|
||
|
|
muted: false,
|
||
|
|
presets: ['FactoryDefaults', 'Movie'],
|
||
|
|
selectedPreset: 'Movie',
|
||
|
|
},
|
||
|
|
media: {
|
||
|
|
currentTrackUri: 'http://media.local/song.mp3',
|
||
|
|
metadata: {
|
||
|
|
title: 'Test Song',
|
||
|
|
artist: 'Test Artist',
|
||
|
|
album: 'Test Album',
|
||
|
|
upnpClass: 'object.item.audioItem.musicTrack',
|
||
|
|
},
|
||
|
|
position: {
|
||
|
|
trackDurationSeconds: 240,
|
||
|
|
relativeTimeSeconds: 12,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
sinkProtocolInfo: ['http-get:*:audio/mpeg:*'],
|
||
|
|
updatedAt: '2026-01-01T00:00:00.000Z',
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
const devices = DlnaDmrMapper.toDevices(snapshot);
|
||
|
|
const entities = DlnaDmrMapper.toEntities(snapshot);
|
||
|
|
expect(devices[0].id).toEqual('dlna_dmr.renderer.uuid_renderer_1');
|
||
|
|
expect(devices[0].state.find((stateArg) => stateArg.featureId === 'playback')?.value).toEqual('playing');
|
||
|
|
expect(entities[0].id).toEqual('media_player.living_room_renderer');
|
||
|
|
expect(entities[0].state).toEqual('playing');
|
||
|
|
expect(entities[0].attributes?.volumeLevel).toEqual(0.42);
|
||
|
|
expect(entities[0].attributes?.mediaContentType).toEqual('music');
|
||
|
|
});
|
||
|
|
|
||
|
|
export default tap.start();
|