From ef92b7911fffb052e96e7b66b152dab01569e14b Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 2 Sep 2023 00:14:03 +0400 Subject: [PATCH] Up Preview test --- .../commands/view/{Preview.js => Preview.ts} | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) rename test/specs/commands/view/{Preview.js => Preview.ts} (80%) diff --git a/test/specs/commands/view/Preview.js b/test/specs/commands/view/Preview.ts similarity index 80% rename from test/specs/commands/view/Preview.js rename to test/specs/commands/view/Preview.ts index abf22c050..b3c91d7a8 100644 --- a/test/specs/commands/view/Preview.js +++ b/test/specs/commands/view/Preview.ts @@ -1,11 +1,14 @@ -import Panel from 'panels/model/Panel'; -import Preview from 'commands/view/Preview'; +import Panel from '../../../../src/panels/model/Panel'; +import Preview from '../../../../src/commands/view/Preview'; describe('Preview command', () => { - let fakePanels, fakeEditor, fakeIsActive; + let fakePanels: Panel[]; + let fakeEditor: any; + let fakeIsActive: any; + const obj: any = {}; beforeEach(() => { - fakePanels = [new Panel(), new Panel(), new Panel()]; + fakePanels = [new Panel(obj, obj), new Panel(obj, obj), new Panel(obj, obj)]; fakeIsActive = false; fakeEditor = { @@ -61,25 +64,25 @@ describe('Preview command', () => { it('should hide all panels', () => { fakePanels.forEach(panel => expect(panel.get('visible')).toEqual(true)); - Preview.run(fakeEditor); + Preview.run!(fakeEditor, obj, obj); fakePanels.forEach(panel => expect(panel.get('visible')).toEqual(false)); }); it("should stop the 'core:component-outline' command if active", () => { - Preview.run(fakeEditor); + Preview.run!(fakeEditor, obj, obj); expect(fakeEditor.stopCommand).not.toHaveBeenCalled(); fakeIsActive = true; - Preview.run(fakeEditor); + Preview.run!(fakeEditor, obj, obj); expect(fakeEditor.stopCommand).toHaveBeenCalledWith('core:component-outline'); }); it('should not reset the `shouldRunSwVisibility` state once active if run multiple times', () => { expect(Preview.shouldRunSwVisibility).toBeUndefined(); fakeIsActive = true; - Preview.run(fakeEditor); + Preview.run!(fakeEditor, obj, obj); expect(Preview.shouldRunSwVisibility).toEqual(true); fakeIsActive = false; - Preview.run(fakeEditor); + Preview.run!(fakeEditor, obj, obj); expect(Preview.shouldRunSwVisibility).toEqual(true); }); }); @@ -87,15 +90,15 @@ describe('Preview command', () => { describe('.stop', () => { it('should show all panels', () => { fakePanels.forEach(panel => panel.set('visible', false)); - Preview.stop(fakeEditor); + Preview.stop!(fakeEditor, obj, obj); fakePanels.forEach(panel => expect(panel.get('visible')).toEqual(true)); }); it("should run the 'core:component-outline' command if it was active before run", () => { - Preview.stop(fakeEditor); + Preview.stop!(fakeEditor, obj, obj); expect(fakeEditor.runCommand).not.toHaveBeenCalled(); Preview.shouldRunSwVisibility = true; - Preview.stop(fakeEditor); + Preview.stop!(fakeEditor, obj, obj); expect(fakeEditor.runCommand).toHaveBeenCalledWith('core:component-outline'); expect(Preview.shouldRunSwVisibility).toEqual(false); });