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