Browse Source

Up Preview test

pull/5399/head
Artur Arseniev 3 years ago
parent
commit
ef92b7911f
  1. 27
      test/specs/commands/view/Preview.ts

27
test/specs/commands/view/Preview.js → test/specs/commands/view/Preview.ts

@ -1,11 +1,14 @@
import Panel from 'panels/model/Panel'; import Panel from '../../../../src/panels/model/Panel';
import Preview from 'commands/view/Preview'; import Preview from '../../../../src/commands/view/Preview';
describe('Preview command', () => { describe('Preview command', () => {
let fakePanels, fakeEditor, fakeIsActive; let fakePanels: Panel[];
let fakeEditor: any;
let fakeIsActive: any;
const obj: any = {};
beforeEach(() => { beforeEach(() => {
fakePanels = [new Panel(), new Panel(), new Panel()]; fakePanels = [new Panel(obj, obj), new Panel(obj, obj), new Panel(obj, obj)];
fakeIsActive = false; fakeIsActive = false;
fakeEditor = { fakeEditor = {
@ -61,25 +64,25 @@ describe('Preview command', () => {
it('should hide all panels', () => { it('should hide all panels', () => {
fakePanels.forEach(panel => expect(panel.get('visible')).toEqual(true)); 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)); fakePanels.forEach(panel => expect(panel.get('visible')).toEqual(false));
}); });
it("should stop the 'core:component-outline' command if active", () => { it("should stop the 'core:component-outline' command if active", () => {
Preview.run(fakeEditor); Preview.run!(fakeEditor, obj, obj);
expect(fakeEditor.stopCommand).not.toHaveBeenCalled(); expect(fakeEditor.stopCommand).not.toHaveBeenCalled();
fakeIsActive = true; fakeIsActive = true;
Preview.run(fakeEditor); Preview.run!(fakeEditor, obj, obj);
expect(fakeEditor.stopCommand).toHaveBeenCalledWith('core:component-outline'); expect(fakeEditor.stopCommand).toHaveBeenCalledWith('core:component-outline');
}); });
it('should not reset the `shouldRunSwVisibility` state once active if run multiple times', () => { it('should not reset the `shouldRunSwVisibility` state once active if run multiple times', () => {
expect(Preview.shouldRunSwVisibility).toBeUndefined(); expect(Preview.shouldRunSwVisibility).toBeUndefined();
fakeIsActive = true; fakeIsActive = true;
Preview.run(fakeEditor); Preview.run!(fakeEditor, obj, obj);
expect(Preview.shouldRunSwVisibility).toEqual(true); expect(Preview.shouldRunSwVisibility).toEqual(true);
fakeIsActive = false; fakeIsActive = false;
Preview.run(fakeEditor); Preview.run!(fakeEditor, obj, obj);
expect(Preview.shouldRunSwVisibility).toEqual(true); expect(Preview.shouldRunSwVisibility).toEqual(true);
}); });
}); });
@ -87,15 +90,15 @@ describe('Preview command', () => {
describe('.stop', () => { describe('.stop', () => {
it('should show all panels', () => { it('should show all panels', () => {
fakePanels.forEach(panel => panel.set('visible', false)); fakePanels.forEach(panel => panel.set('visible', false));
Preview.stop(fakeEditor); Preview.stop!(fakeEditor, obj, obj);
fakePanels.forEach(panel => expect(panel.get('visible')).toEqual(true)); fakePanels.forEach(panel => expect(panel.get('visible')).toEqual(true));
}); });
it("should run the 'core:component-outline' command if it was active before run", () => { 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(); expect(fakeEditor.runCommand).not.toHaveBeenCalled();
Preview.shouldRunSwVisibility = true; Preview.shouldRunSwVisibility = true;
Preview.stop(fakeEditor); Preview.stop!(fakeEditor, obj, obj);
expect(fakeEditor.runCommand).toHaveBeenCalledWith('core:component-outline'); expect(fakeEditor.runCommand).toHaveBeenCalledWith('core:component-outline');
expect(Preview.shouldRunSwVisibility).toEqual(false); expect(Preview.shouldRunSwVisibility).toEqual(false);
}); });
Loading…
Cancel
Save