2020-05-08 05:09:39 -04:00
|
|
|
import { mockTracking } from 'helpers/tracking_helper';
|
|
|
|
import { trackDesignDetailView } from '~/design_management/utils/tracking';
|
|
|
|
|
|
|
|
function getTrackingSpy(key) {
|
|
|
|
return mockTracking(key, undefined, jest.spyOn);
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Tracking Events', () => {
|
|
|
|
describe('trackDesignDetailView', () => {
|
|
|
|
const eventKey = 'projects:issues:design';
|
|
|
|
const eventName = 'design_viewed';
|
|
|
|
|
|
|
|
it('trackDesignDetailView fires a tracking event when called', () => {
|
|
|
|
const trackingSpy = getTrackingSpy(eventKey);
|
|
|
|
|
|
|
|
trackDesignDetailView();
|
|
|
|
|
|
|
|
expect(trackingSpy).toHaveBeenCalledWith(
|
|
|
|
eventKey,
|
|
|
|
eventName,
|
|
|
|
expect.objectContaining({
|
|
|
|
label: eventName,
|
|
|
|
value: {
|
|
|
|
'internal-object-refrerer': '',
|
2020-05-12 05:09:31 -04:00
|
|
|
'design-collection-owner': '',
|
|
|
|
'design-version-number': 1,
|
|
|
|
'design-is-current-version': false,
|
2020-05-08 05:09:39 -04:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('trackDesignDetailView allows to customize the value payload', () => {
|
|
|
|
const trackingSpy = getTrackingSpy(eventKey);
|
|
|
|
|
2020-05-12 05:09:31 -04:00
|
|
|
trackDesignDetailView('from-a-test', 'test', 100, true);
|
2020-05-08 05:09:39 -04:00
|
|
|
|
|
|
|
expect(trackingSpy).toHaveBeenCalledWith(
|
|
|
|
eventKey,
|
|
|
|
eventName,
|
|
|
|
expect.objectContaining({
|
|
|
|
label: eventName,
|
|
|
|
value: {
|
|
|
|
'internal-object-refrerer': 'from-a-test',
|
2020-05-12 05:09:31 -04:00
|
|
|
'design-collection-owner': 'test',
|
|
|
|
'design-version-number': 100,
|
|
|
|
'design-is-current-version': true,
|
2020-05-08 05:09:39 -04:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|