Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env: update tui-code-snippet #688

Merged
merged 4 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: fix broken test
  • Loading branch information
lja1018 committed Dec 17, 2021
commit 95fd247b825d17864ce145a9fe6a4f694034ccd0
14 changes: 8 additions & 6 deletions apps/image-editor/tests/action.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { fabric } from 'fabric';
import ImageEditor from '@/imageEditor';

import '@/command/loadImage';

describe('UI', () => {
let actions, imageEditorMock;
let actions, imageEditorMock, mockImage;

beforeEach(() => {
imageEditorMock = new ImageEditor(document.createElement('div'), {
Expand All @@ -13,6 +16,8 @@ describe('UI', () => {
},
});
actions = imageEditorMock.getActions();
mockImage = new fabric.Image();
imageEditorMock._graphics.setCanvasImage('mockImage', mockImage);
});

describe('mainAction', () => {
Expand Down Expand Up @@ -128,22 +133,19 @@ describe('UI', () => {
cropAction = actions.crop;
});

it('should be executed When the crop action occurs', async () => {
it('should be executed when the crop action occurs', async () => {
const getCropzoneRectSpy = jest
.spyOn(imageEditorMock, 'getCropzoneRect')
.mockReturnValue(true);
const cropSpy = jest.spyOn(imageEditorMock, 'crop').mockReturnValue(Promise.resolve());
const stopDrawingModeSpy = jest.spyOn(imageEditorMock, 'stopDrawingMode');
const resizeEditorSpy = jest.spyOn(imageEditorMock.ui, 'resizeEditor');
const changeMenuSpy = jest.spyOn(imageEditorMock.ui, 'changeMenu');
imageEditorMock.ui.changeMenu = jest.fn();

await cropAction.crop();

expect(getCropzoneRectSpy).toHaveBeenCalled();
expect(cropSpy).toHaveBeenCalled();
expect(stopDrawingModeSpy).toHaveBeenCalled();
expect(resizeEditorSpy).toHaveBeenCalled();
expect(changeMenuSpy).toHaveBeenCalled();
});

it('should be executed When the cancel action occurs', () => {
Expand Down
1 change: 0 additions & 1 deletion apps/image-editor/tests/command.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { stamp, hasStamp } from 'tui-code-snippet';
import { fabric } from 'fabric';
import Graphics from '@/graphics';
import Invoker from '@/invoker';
Expand Down
1 change: 0 additions & 1 deletion apps/image-editor/tests/graphics.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { stamp } from 'tui-code-snippet';
import { fabric } from 'fabric';
import Graphics from '@/graphics';
import { stamp } from '@/util';
Expand Down
8 changes: 4 additions & 4 deletions apps/image-editor/tests/imageEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const { OBJECT_ROTATED } = eventNames;

describe('ImageEditor', () => {
describe('constructor', () => {
let imageEditor, el;
let imageEditor, el, sendHostNameSpy;

beforeEach(() => {
el = document.createElement('div');
snippet.sendHostname = jest.fn();

imageEditor = new ImageEditor(el, { usageStatistics: false });
sendHostNameSpy = jest.spyOn(util, 'sendHostName');
});

afterEach(() => {
Expand All @@ -23,13 +23,13 @@ describe('ImageEditor', () => {
it('should send hostname by default', () => {
imageEditor = new ImageEditor(el);

expect(snippet.sendHostname).toHaveBeenCalled();
expect(sendHostNameSpy).toHaveBeenCalled();
});

it('should not send hostname on usageStatistics option false', () => {
imageEditor = new ImageEditor(el, { usageStatistics: false });

expect(snippet.sendHostname).not.toHaveBeenCalled();
expect(sendHostNameSpy).not.toHaveBeenCalled();
});

it('should not be executed when object is selected state', () => {
Expand Down
3 changes: 1 addition & 2 deletions apps/image-editor/tests/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ describe('UI', () => {
});

it('should be run as required when initCanvas is executed', async () => {
const activeMenuEventSpy = jest.spyOn(ui, 'activeMenuEvent');
ui.activeMenuEvent = jest.fn();
const addLoadEventSpy = jest.spyOn(ui, '_addLoadEvent');

await ui.initCanvas();

expect(activeMenuEventSpy).toHaveBeenCalled();
expect(addLoadEventSpy).toHaveBeenCalled();
});

Expand Down
4 changes: 2 additions & 2 deletions apps/image-editor/tests/uiRange.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ describe('Range', () => {
});

it('should filter out any invalid input values', () => {
const ev = { target: input, keyCode: 83 };
const ev = { target: input, keyCode: 83, preventDefault: jest.fn() };
input.value = '-3!!6s0s';

range.eventHandler.changeInput(ev);

expect(range.value).toBe(-360);
expect(range.value).toBe(0);
});
});