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

const snapshot = {
  speakerInfo: {
    uid: 'RINCON_000E58ABCDEF01400',
    zoneName: 'Kitchen',
    modelName: 'Sonos One',
    manufacturer: 'Sonos',
  },
  transportInfo: {
    currentTransportState: 'PLAYING',
  },
  positionInfo: {
    title: 'Example Track',
    artist: 'Example Artist',
    album: 'Example Album',
    trackUri: 'x-sonos-http:track',
  },
  volume: 35,
  muted: false,
};

tap.test('maps Sonos speaker snapshots to canonical media devices and entities', async () => {
  const devices = SonosMapper.toDevices(snapshot);
  const entities = SonosMapper.toEntities(snapshot);
  expect(devices[0].id).toEqual('sonos.player.rincon_000e58abcdef01400');
  expect(devices[0].features.some((featureArg) => featureArg.id === 'volume')).toBeTrue();
  expect(entities[0].platform).toEqual('media_player');
  expect(entities[0].state).toEqual('playing');
});

export default tap.start();
