@comparaonline/event-tracker
Version:
This library it's an interface between any frontend application and some event tracking platforms, currently Snowplow and Tag Manager.
35 lines (30 loc) • 980 B
text/typescript
/**
* @jest-environment jsdom
*/
import { track } from '../../trackers';
import { EVENT_NAME, COUNTRY_CODE, BUSINESS_UNIT } from '../../constants';
import { trackToHeap } from '../../trackers/heap';
import { trackToABTasty } from '../../trackers/abtasty';
jest.mock('../../trackers/heap');
jest.mock('../../trackers/abtasty');
describe('OTP Error Event Tracking', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('should track OTP error events through the main track function', () => {
const otpErrorEvent = {
name: EVENT_NAME.OTP_ERROR,
data: {
app_name: 'test-app',
app_version: '1.0.0',
country_code: COUNTRY_CODE.CL,
business_unit: BUSINESS_UNIT.CAR_INSURANCE,
user_type: 'anonymous',
error_code: 'otp-invalid',
},
};
track(otpErrorEvent);
expect(trackToHeap).toHaveBeenCalledWith(otpErrorEvent);
expect(trackToABTasty).toHaveBeenCalledWith(otpErrorEvent);
});
});