mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-02-06 07:23:00 -05:00
feat: utils/actions unit tests
This commit is contained in:
39
frontend/tests/utils/actions/PlaylistViewActions.test.ts
Normal file
39
frontend/tests/utils/actions/PlaylistViewActions.test.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { PlaylistViewActions } from '../../../src/static/js/utils/actions';
|
||||
import dispatcher from '../../../src/static/js/utils/dispatcher';
|
||||
|
||||
// Mock the dispatcher module used by PlaylistViewActions
|
||||
jest.mock('../../../src/static/js/utils/dispatcher', () => ({ dispatch: jest.fn() }));
|
||||
|
||||
describe('utils/actions', () => {
|
||||
describe('PlaylistViewActions', () => {
|
||||
const dispatch = dispatcher.dispatch;
|
||||
|
||||
beforeEach(() => {
|
||||
(dispatcher.dispatch as jest.Mock).mockClear();
|
||||
});
|
||||
|
||||
describe('toggleLoop', () => {
|
||||
it('Should dispatch TOGGLE_LOOP action', () => {
|
||||
PlaylistViewActions.toggleLoop();
|
||||
expect(dispatch).toHaveBeenCalledTimes(1);
|
||||
expect(dispatch).toHaveBeenCalledWith({ type: 'TOGGLE_LOOP' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('toggleShuffle', () => {
|
||||
it('Should dispatch TOGGLE_SHUFFLE action', () => {
|
||||
PlaylistViewActions.toggleShuffle();
|
||||
expect(dispatch).toHaveBeenCalledTimes(1);
|
||||
expect(dispatch).toHaveBeenCalledWith({ type: 'TOGGLE_SHUFFLE' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('toggleSave', () => {
|
||||
it('Should dispatch TOGGLE_SAVE action', () => {
|
||||
PlaylistViewActions.toggleSave();
|
||||
expect(dispatch).toHaveBeenCalledTimes(1);
|
||||
expect(dispatch).toHaveBeenCalledWith({ type: 'TOGGLE_SAVE' });
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user