2020-02-04 08:43:56 +03:00
|
|
|
import { types } from '.';
|
|
|
|
import { createGaSaga } from './ga-saga';
|
|
|
|
import ga from '../analytics';
|
|
|
|
import { expectSaga } from 'redux-saga-test-plan';
|
|
|
|
|
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: {
|
2020-12-07 16:35:28 +03:00
|
|
|
category: 'Donation',
|
2020-02-04 08:43:56 +03:00
|
|
|
action: 'year end gift paypal button click'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
expectSaga(createGaSaga, types)
|
|
|
|
// Assert that the `call` with expected pramater will eventually happen.
|
|
|
|
.call(GaTypes.event, mockEventPayload.data)
|
|
|
|
|
|
|
|
// Dispatch any actions that the saga will `take`.
|
|
|
|
.dispatch({ type: types.executeGA, payload: mockEventPayload })
|
|
|
|
|
|
|
|
// Start the test.
|
|
|
|
.run()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|