diff --git a/spec/annotateArea.spec.tsx b/spec/annotateArea.spec.tsx
index 276f21c4..122dd2f3 100644
--- a/spec/annotateArea.spec.tsx
+++ b/spec/annotateArea.spec.tsx
@@ -2,7 +2,7 @@ import { mount } from 'enzyme';
import * as React from 'react';
import AnnotateArea from '../src/renderer/components/annotate-area';
import { Tool } from '../src/renderer/components/snipping-tool';
-import * as analyticsHandler from './../src/app/analytics-handler';
+import { ipcRenderer } from './__mocks__/electron';
const defaultProps = {
paths: [],
@@ -127,7 +127,7 @@ describe('', () => {
});
it('should send annotate_erased if clicked on path with tool eraser', () => {
- const spy = jest.spyOn(analyticsHandler.analytics, 'track');
+ const spy = jest.spyOn(ipcRenderer, 'send');
const pathProps = {
paths: [{
points: [{ x: 0, y: 0 }],
@@ -146,19 +146,19 @@ describe('', () => {
};
const wrapper = mount();
const path = wrapper.find('[data-testid="path0"]');
- const expectedValue = { action_type: 'annotate_erased', element: 'screen_capture_annotate' };
+ const expectedValue = { type: 'annotate_erased', element: 'screen_capture_annotate' };
path.simulate('click');
- expect(spy).toBeCalledWith(expectedValue);
+ expect(spy).toBeCalledWith('send-tracking-data-to-main', expectedValue);
});
it('should send annotate_added_pen event when drawn with pen', () => {
- const spy = jest.spyOn(analyticsHandler.analytics, 'track');
- const expectedValue = { action_type: 'annotate_added_pen', element: 'screen_capture_annotate' };
+ const spy = jest.spyOn(ipcRenderer, 'send');
+ const expectedValue = { type: 'annotate_added_pen', element: 'screen_capture_annotate' };
const wrapper = mount();
const area = wrapper.find('[data-testid="annotate-area"]');
area.simulate('mousedown', { pageX: 2, pageY: 49 });
area.simulate('mouseup');
- expect(spy).toBeCalledWith(expectedValue);
+ expect(spy).toBeCalledWith('send-tracking-data-to-main', expectedValue);
});
it('should send annotate_added_highlight event when drawn with highlight', () => {
@@ -172,12 +172,12 @@ describe('', () => {
chosenTool: Tool.highlight,
screenSnippetPath: 'very-nice-path',
};
- const spy = jest.spyOn(analyticsHandler.analytics, 'track');
- const expectedValue = { action_type: 'annotate_added_highlight', element: 'screen_capture_annotate' };
+ const spy = jest.spyOn(ipcRenderer, 'send');
+ const expectedValue = { type: 'annotate_added_highlight', element: 'screen_capture_annotate' };
const wrapper = mount();
const area = wrapper.find('[data-testid="annotate-area"]');
area.simulate('mousedown', { pageX: 2, pageY: 49 });
area.simulate('mouseup');
- expect(spy).toBeCalledWith(expectedValue);
+ expect(spy).toBeCalledWith('send-tracking-data-to-main', expectedValue);
});
});
diff --git a/spec/snippingTool.spec.tsx b/spec/snippingTool.spec.tsx
index 4eba4c49..4aab3fcb 100644
--- a/spec/snippingTool.spec.tsx
+++ b/spec/snippingTool.spec.tsx
@@ -1,7 +1,6 @@
import { mount, shallow } from 'enzyme';
import * as React from 'react';
import SnippingTool from '../src/renderer/components/snipping-tool';
-import * as analyticsHandler from './../src/app/analytics-handler';
import { ipcRenderer } from './__mocks__/electron';
const waitForPromisesToResolve = () => new Promise((resolve) => setTimeout(resolve));
@@ -23,30 +22,30 @@ describe('Snipping Tool', () => {
});
it('should send screenshot_taken BI event on component mount', () => {
- const spy = jest.spyOn(analyticsHandler.analytics, 'track');
- const expectedValue = { action_type: 'screenshot_taken', element: 'screen_capture_annotate' };
+ const spy = jest.spyOn(ipcRenderer, 'send');
+ const expectedValue = { type: 'screenshot_taken', element: 'screen_capture_annotate' };
mount(React.createElement(SnippingTool));
- expect(spy).toBeCalledWith(expectedValue);
+ expect(spy).toBeCalledWith('send-tracking-data-to-main', expectedValue);
});
it('should send capture_sent BI event when clicking done', async () => {
- const spy = jest.spyOn(analyticsHandler.analytics, 'track');
- const expectedValue = { action_type: 'annotate_done', element: 'screen_capture_annotate' };
+ const spy = jest.spyOn(ipcRenderer, 'send');
+ const expectedValue = { type: 'annotate_done', element: 'screen_capture_annotate' };
const wrapper = mount(React.createElement(SnippingTool));
wrapper.find('[data-testid="done-button"]').simulate('click');
wrapper.update();
await waitForPromisesToResolve();
- expect(spy).toBeCalledWith(expectedValue);
+ expect(spy).toBeCalledWith('send-tracking-data-to-main', expectedValue);
});
it('should send annotate_cleared BI event when clicking clear', async () => {
- const spy = jest.spyOn(analyticsHandler.analytics, 'track');
- const expectedValue = { action_type: 'annotate_cleared', element: 'screen_capture_annotate' };
+ const spy = jest.spyOn(ipcRenderer, 'send');
+ const expectedValue = { type: 'annotate_cleared', element: 'screen_capture_annotate' };
const wrapper = mount(React.createElement(SnippingTool));
wrapper.find('[data-testid="clear-button"]').simulate('click');
wrapper.update();
await waitForPromisesToResolve();
- expect(spy).toBeCalledWith(expectedValue);
+ expect(spy).toBeCalledWith('send-tracking-data-to-main', expectedValue);
});
it('should render pen color picker when clicked on pen', () => {