@kiwicom/smart-faq
Version:
Smart FAQ
45 lines (37 loc) • 1.18 kB
JavaScript
// @flow
import * as React from 'react';
import { shallow } from 'enzyme';
import MockDate from 'mockdate';
import { simpleTracker } from '../../../shared/helpers/analytics/trackers';
import { RawBookingAnalyticsTracker } from '../BookingAnalyticsTracker';
jest.mock('../../../shared/helpers/analytics/trackers', () => ({
simpleTracker: jest.fn(),
}));
describe('BookingAnalyticsTracker', () => {
beforeEach(() => MockDate.set('2018-01-01T00:00:00.000Z', { zone: 'utc' }));
afterEach(() => MockDate.reset());
it('should send remaining time to departure to analytics', () => {
const mockRefType: any = null;
const booking = {
$refType: mockRefType,
id: 'abc123==',
type: 'BookingOneWay',
upcomingDeparture: {
departure: {
time: '2018-01-01T04:00:00.000Z',
},
},
trip: {
departure: {
time: '2018-01-01T02:00:00.000Z',
},
},
};
shallow(<RawBookingAnalyticsTracker booking={booking} />);
expect(simpleTracker).toHaveBeenCalledWith('smartFAQBookingOverview', {
action: 'bookingLoaded',
timeToSegment: 4,
timeToDeparture: 2,
});
});
});