blob: 5dff9b6f1180e18ecf718a904601ed1fe8db56a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { snakeCase } from 'lodash';
import { handleTracking } from '~/ide/lib/gitlab_web_ide/handle_tracking_event';
import { convertObjectPropsToSnakeCase } from '~/lib/utils/common_utils';
import { mockTracking } from 'helpers/tracking_helper';
describe('ide/handle_tracking_event', () => {
let trackingSpy;
beforeEach(() => {
trackingSpy = mockTracking(undefined, null, jest.spyOn);
});
describe('when the event does not contain data', () => {
it('does not send extra property to snowplow', () => {
const event = { name: 'event-name' };
handleTracking(event);
expect(trackingSpy).toHaveBeenCalledWith(undefined, snakeCase(event.name));
});
});
describe('when the event contains data', () => {
it('sends extra property to snowplow', () => {
const event = { name: 'event-name', data: { 'extra-details': 'details' } };
handleTracking(event);
expect(trackingSpy).toHaveBeenCalledWith(undefined, snakeCase(event.name), {
extra: convertObjectPropsToSnakeCase(event.data),
});
});
});
});
|