feat: utils/actions unit tests

This commit is contained in:
Yiannis
2026-01-24 20:00:20 +02:00
parent 1c15880ae3
commit 08189191b5
10 changed files with 652 additions and 41 deletions

View 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' });
});
});
});