Files
advanced-camera-card/tests/card-controller/actions/actions/mute.test.ts
T
Dermot Duffy 3b77b11196 fix: Increase reliability of media auto actions (e.g. play) (#1934)
Refactors media player handling entirely to make the code more
consistent and less boilerplate. Add testing for media player actions.

- Closes #1921
- Closes #1916
2025-03-03 20:59:01 -08:00

27 lines
805 B
TypeScript

import { expect, it, vi } from 'vitest';
import { mock } from 'vitest-mock-extended';
import { MuteAction } from '../../../../src/card-controller/actions/actions/mute';
import { MediaPlayerController } from '../../../../src/types';
import { createCardAPI, createMediaLoadedInfo } from '../../../test-utils';
it('should handle mute action', async () => {
const api = createCardAPI();
const mediaPlayerController = mock<MediaPlayerController>();
vi.mocked(api.getMediaLoadedInfoManager().get).mockReturnValue(
createMediaLoadedInfo({
mediaPlayerController,
}),
);
const action = new MuteAction(
{},
{
action: 'fire-dom-event',
advanced_camera_card_action: 'mute',
},
);
await action.execute(api);
expect(mediaPlayerController.mute).toBeCalled();
});