@kiwicom/smart-faq
Version:
58 lines (51 loc) • 1.39 kB
JavaScript
// @flow
import * as React from 'react';
import { mount } from 'enzyme';
import MockDate from 'mockdate';
import LogContext from '@kiwicom/nitro/lib/services/log/context';
import { RawBookingAnalyticsTracker } from '../BookingAnalyticsTracker';
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 log = jest.fn();
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',
},
},
};
mount(
<LogContext.Provider value={{ log }}>
<RawBookingAnalyticsTracker booking={booking} />
</LogContext.Provider>,
);
expect(log).toHaveBeenCalledWith(
{
category: 'SmartFAQ',
subCategory: 'BookingOverview',
action: 'bookingLoaded',
destinations: {
bigQuery: true,
exponea: false,
ga: false,
logmole: true,
},
},
{
timeToSegment: 4,
timeToDeparture: 2,
},
);
});
});