- Closes #2556 - Closes #2450 **Key intended features:** - go2rtc compatible - 100% test coverage to significantly improve ability to test, maintain and work around browser weirdnesses (e.g. Safari). - Written from the ground up in the style of the rest of the project. **To use:** - Change `live_provider` from `go2rtc` to `go2rtc-experimental`.
30 lines
882 B
TypeScript
30 lines
882 B
TypeScript
import { expect, it, vi } from 'vitest';
|
|
import { mock } from 'vitest-mock-extended';
|
|
|
|
import { PlayAction } from '../../../../src/card-controller/actions/actions/play';
|
|
import type { MediaPlayerController, PlaybackControl } from '../../../../src/types';
|
|
import { createCardAPI, createMediaLoadedInfo } from '../../../test-utils';
|
|
|
|
it('should handle play action', async () => {
|
|
const api = createCardAPI();
|
|
const mediaPlayerController = mock<MediaPlayerController>({
|
|
playback: mock<PlaybackControl>(),
|
|
});
|
|
vi.mocked(api.getMediaLoadedInfoManager().get).mockReturnValue(
|
|
createMediaLoadedInfo({
|
|
mediaPlayerController,
|
|
}),
|
|
);
|
|
const action = new PlayAction(
|
|
{},
|
|
{
|
|
action: 'fire-dom-event',
|
|
advanced_camera_card_action: 'play',
|
|
},
|
|
);
|
|
|
|
await action.execute(api);
|
|
|
|
expect(mediaPlayerController.playback?.play).toBeCalled();
|
|
});
|