2020-02-04 08:43:56 +03:00
|
|
|
import { expectSaga } from 'redux-saga-test-plan';
|
2021-08-02 15:39:40 +02:00
|
|
|
import ga from '../analytics';
|
|
|
|
import { actionTypes } from './action-types';
|
|
|
|
import { createGaSaga } from './ga-saga';
|
2020-02-04 08:43:56 +03:00
|
|
|
|
2021-03-30 01:48:58 +02:00
|
|
|
jest.mock('../analytics');
|
|
|
|
|
2020-02-04 08:43:56 +03:00
|
|
|
describe('ga-saga', () => {
|
|
|
|
it('calls GA after executeGA action', () => {
|
|
|
|
const GaTypes = { event: ga.event, page: ga.pageview, modal: ga.modalview };
|
|
|
|
const mockEventPayload = {
|
|
|
|
type: 'event',
|
|
|
|
data: {
|
2021-11-22 16:43:28 +03:00
|
|
|
category: 'Map Challenge Click',
|
|
|
|
action: '/learn'
|
2020-02-04 08:43:56 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
return (
|
2021-08-02 15:39:40 +02:00
|
|
|
expectSaga(createGaSaga, actionTypes)
|
2021-10-02 21:03:19 +08:00
|
|
|
// Assert that the `call` with expected paramater will eventually happen.
|
2020-02-04 08:43:56 +03:00
|
|
|
.call(GaTypes.event, mockEventPayload.data)
|
|
|
|
|
|
|
|
// Dispatch any actions that the saga will `take`.
|
2021-08-02 15:39:40 +02:00
|
|
|
.dispatch({ type: actionTypes.executeGA, payload: mockEventPayload })
|
2020-02-04 08:43:56 +03:00
|
|
|
|
|
|
|
// Start the test.
|
|
|
|
.run()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|