Skip to content

Commit

Permalink
fix(highlight): Update highlight canvas unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
karelee7 committed Aug 2, 2022
1 parent 2068221 commit 97b1399
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/highlight/__mocks__/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const selection = {
],
};

export const ref = {
export const canvasContext = {
fillRect: jest.fn(),
restore: jest.fn(),
save: jest.fn(),
Expand Down
8 changes: 4 additions & 4 deletions src/highlight/__tests__/HighlightCanvas-test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import HighlightCanvas, { Props } from '../HighlightCanvas';
import { rect as mockRect, ref, noWidthRect, noHeightRect } from '../__mocks__/data';
import { canvasContext, rect as mockRect, noWidthRect, noHeightRect } from '../__mocks__/data';

describe('HighlightCanvas', () => {
const defaults: Props = {
Expand Down Expand Up @@ -64,14 +64,14 @@ describe('HighlightCanvas', () => {
current: {
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
getContext: () => ref,
getContext: () => canvasContext,
},
};

instance.renderRects();

expect(ref.fillRect).toHaveBeenCalledTimes(1);
expect(ref.strokeRect).toHaveBeenCalledTimes(1);
expect(canvasContext.fillRect).toHaveBeenCalledTimes(1);
expect(canvasContext.strokeRect).toHaveBeenCalledTimes(1);
});
});
});

0 comments on commit 97b1399

Please sign in to comment.