Skip to content
Snippets Groups Projects
Commit d8d1b50a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

test checking if toast is shown

parent 0767bf6f
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!199Resolve "[MIN-321] form for reporting errors in minerva"
Pipeline #90493 passed
import { store } from '@/redux/store';
import { showToast } from '@/utils/showToast';
import { errorMiddlewareListener } from './error.middleware';
jest.mock('../../utils/showToast');
describe('errorMiddlewareListener', () => {
const dispatchSpy = jest.spyOn(store, 'dispatch');
......@@ -128,4 +131,27 @@ describe('errorMiddlewareListener', () => {
}),
);
});
it('should toast on access denied', async () => {
const action = {
type: 'action/rejected',
payload: null,
meta: {
requestId: '421',
rejectedWithValue: true,
requestStatus: 'rejected',
},
error: {
code: '403',
},
};
const { getState, dispatch } = store;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
await errorMiddlewareListener(action, { getState, dispatch });
expect(showToast).toHaveBeenCalledWith({
message: 'Access denied.',
type: 'error',
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment