mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-02-04 06:22:59 -05:00
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import { SearchFieldActions } from '../../../src/static/js/utils/actions';
|
|
import dispatcher from '../../../src/static/js/utils/dispatcher';
|
|
|
|
// Mock the dispatcher module used by SearchFieldActions
|
|
jest.mock('../../../src/static/js/utils/dispatcher', () => ({ dispatch: jest.fn() }));
|
|
|
|
describe('utils/actions', () => {
|
|
describe('SearchFieldActions', () => {
|
|
const dispatch = dispatcher.dispatch;
|
|
|
|
beforeEach(() => {
|
|
(dispatcher.dispatch as jest.Mock).mockClear();
|
|
});
|
|
|
|
describe('requestPredictions', () => {
|
|
it('Should dispatch REQUEST_PREDICTIONS with provided query strings', () => {
|
|
SearchFieldActions.requestPredictions('cats');
|
|
SearchFieldActions.requestPredictions('');
|
|
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
expect(dispatch).toHaveBeenNthCalledWith(1, { type: 'REQUEST_PREDICTIONS', query: 'cats' });
|
|
expect(dispatch).toHaveBeenNthCalledWith(2, { type: 'REQUEST_PREDICTIONS', query: '' });
|
|
});
|
|
});
|
|
});
|
|
});
|