mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-28 09:51:06 -06:00
SDA-2751 Fixed UTs
This commit is contained in:
parent
4ab878cbfb
commit
4d9f3fc9ee
@ -2,7 +2,7 @@ import { mount } from 'enzyme';
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import AnnotateArea from '../src/renderer/components/annotate-area';
|
import AnnotateArea from '../src/renderer/components/annotate-area';
|
||||||
import { Tool } from '../src/renderer/components/snipping-tool';
|
import { Tool } from '../src/renderer/components/snipping-tool';
|
||||||
import * as analyticsHandler from './../src/app/analytics-handler';
|
import { ipcRenderer } from './__mocks__/electron';
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
paths: [],
|
paths: [],
|
||||||
@ -127,7 +127,7 @@ describe('<AnnotateArea/>', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should send annotate_erased if clicked on path with tool eraser', () => {
|
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 = {
|
const pathProps = {
|
||||||
paths: [{
|
paths: [{
|
||||||
points: [{ x: 0, y: 0 }],
|
points: [{ x: 0, y: 0 }],
|
||||||
@ -146,19 +146,19 @@ describe('<AnnotateArea/>', () => {
|
|||||||
};
|
};
|
||||||
const wrapper = mount(<AnnotateArea {...pathProps} />);
|
const wrapper = mount(<AnnotateArea {...pathProps} />);
|
||||||
const path = wrapper.find('[data-testid="path0"]');
|
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');
|
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', () => {
|
it('should send annotate_added_pen event when drawn with pen', () => {
|
||||||
const spy = jest.spyOn(analyticsHandler.analytics, 'track');
|
const spy = jest.spyOn(ipcRenderer, 'send');
|
||||||
const expectedValue = { action_type: 'annotate_added_pen', element: 'screen_capture_annotate' };
|
const expectedValue = { type: 'annotate_added_pen', element: 'screen_capture_annotate' };
|
||||||
const wrapper = mount(<AnnotateArea {...defaultProps} />);
|
const wrapper = mount(<AnnotateArea {...defaultProps} />);
|
||||||
const area = wrapper.find('[data-testid="annotate-area"]');
|
const area = wrapper.find('[data-testid="annotate-area"]');
|
||||||
area.simulate('mousedown', { pageX: 2, pageY: 49 });
|
area.simulate('mousedown', { pageX: 2, pageY: 49 });
|
||||||
area.simulate('mouseup');
|
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', () => {
|
it('should send annotate_added_highlight event when drawn with highlight', () => {
|
||||||
@ -172,12 +172,12 @@ describe('<AnnotateArea/>', () => {
|
|||||||
chosenTool: Tool.highlight,
|
chosenTool: Tool.highlight,
|
||||||
screenSnippetPath: 'very-nice-path',
|
screenSnippetPath: 'very-nice-path',
|
||||||
};
|
};
|
||||||
const spy = jest.spyOn(analyticsHandler.analytics, 'track');
|
const spy = jest.spyOn(ipcRenderer, 'send');
|
||||||
const expectedValue = { action_type: 'annotate_added_highlight', element: 'screen_capture_annotate' };
|
const expectedValue = { type: 'annotate_added_highlight', element: 'screen_capture_annotate' };
|
||||||
const wrapper = mount(<AnnotateArea {...highlightProps} />);
|
const wrapper = mount(<AnnotateArea {...highlightProps} />);
|
||||||
const area = wrapper.find('[data-testid="annotate-area"]');
|
const area = wrapper.find('[data-testid="annotate-area"]');
|
||||||
area.simulate('mousedown', { pageX: 2, pageY: 49 });
|
area.simulate('mousedown', { pageX: 2, pageY: 49 });
|
||||||
area.simulate('mouseup');
|
area.simulate('mouseup');
|
||||||
expect(spy).toBeCalledWith(expectedValue);
|
expect(spy).toBeCalledWith('send-tracking-data-to-main', expectedValue);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { mount, shallow } from 'enzyme';
|
import { mount, shallow } from 'enzyme';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import SnippingTool from '../src/renderer/components/snipping-tool';
|
import SnippingTool from '../src/renderer/components/snipping-tool';
|
||||||
import * as analyticsHandler from './../src/app/analytics-handler';
|
|
||||||
import { ipcRenderer } from './__mocks__/electron';
|
import { ipcRenderer } from './__mocks__/electron';
|
||||||
|
|
||||||
const waitForPromisesToResolve = () => new Promise((resolve) => setTimeout(resolve));
|
const waitForPromisesToResolve = () => new Promise((resolve) => setTimeout(resolve));
|
||||||
@ -23,30 +22,30 @@ describe('Snipping Tool', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should send screenshot_taken BI event on component mount', () => {
|
it('should send screenshot_taken BI event on component mount', () => {
|
||||||
const spy = jest.spyOn(analyticsHandler.analytics, 'track');
|
const spy = jest.spyOn(ipcRenderer, 'send');
|
||||||
const expectedValue = { action_type: 'screenshot_taken', element: 'screen_capture_annotate' };
|
const expectedValue = { type: 'screenshot_taken', element: 'screen_capture_annotate' };
|
||||||
mount(React.createElement(SnippingTool));
|
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 () => {
|
it('should send capture_sent BI event when clicking done', async () => {
|
||||||
const spy = jest.spyOn(analyticsHandler.analytics, 'track');
|
const spy = jest.spyOn(ipcRenderer, 'send');
|
||||||
const expectedValue = { action_type: 'annotate_done', element: 'screen_capture_annotate' };
|
const expectedValue = { type: 'annotate_done', element: 'screen_capture_annotate' };
|
||||||
const wrapper = mount(React.createElement(SnippingTool));
|
const wrapper = mount(React.createElement(SnippingTool));
|
||||||
wrapper.find('[data-testid="done-button"]').simulate('click');
|
wrapper.find('[data-testid="done-button"]').simulate('click');
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
await waitForPromisesToResolve();
|
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 () => {
|
it('should send annotate_cleared BI event when clicking clear', async () => {
|
||||||
const spy = jest.spyOn(analyticsHandler.analytics, 'track');
|
const spy = jest.spyOn(ipcRenderer, 'send');
|
||||||
const expectedValue = { action_type: 'annotate_cleared', element: 'screen_capture_annotate' };
|
const expectedValue = { type: 'annotate_cleared', element: 'screen_capture_annotate' };
|
||||||
const wrapper = mount(React.createElement(SnippingTool));
|
const wrapper = mount(React.createElement(SnippingTool));
|
||||||
wrapper.find('[data-testid="clear-button"]').simulate('click');
|
wrapper.find('[data-testid="clear-button"]').simulate('click');
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
await waitForPromisesToResolve();
|
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', () => {
|
it('should render pen color picker when clicked on pen', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user