|
|
|
@ -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); |
|
|
|
}); |