mirror of https://github.com/artf/grapesjs.git
3 changed files with 29 additions and 6 deletions
@ -1,8 +1,13 @@ |
|||||
import { CommandObject } from './CommandAbstract'; |
import type { CommandPublicFnFromHandler } from '../registryHelpers'; |
||||
|
import CommandAbstract from './CommandAbstract'; |
||||
|
|
||||
export default { |
export interface CanvasClearCommandRegistryRun { |
||||
run(ed) { |
'core:canvas-clear': CommandPublicFnFromHandler<CommandCanvasClear['run']>; |
||||
|
} |
||||
|
|
||||
|
export default class CommandCanvasClear extends CommandAbstract { |
||||
|
run(ed: any) { |
||||
ed.Components.clear(); |
ed.Components.clear(); |
||||
ed.Css.clear(); |
ed.Css.clear(); |
||||
}, |
} |
||||
} as CommandObject; |
} |
||||
|
|||||
@ -0,0 +1,16 @@ |
|||||
|
import CanvasClear from '../../../../src/commands/view/CanvasClear'; |
||||
|
|
||||
|
describe('CanvasClear command', () => { |
||||
|
test('should clear components and css', () => { |
||||
|
const command = new CanvasClear({}); |
||||
|
const editor = { |
||||
|
Components: { clear: jest.fn() }, |
||||
|
Css: { clear: jest.fn() }, |
||||
|
}; |
||||
|
|
||||
|
command.run(editor); |
||||
|
|
||||
|
expect(editor.Components.clear).toHaveBeenCalledTimes(1); |
||||
|
expect(editor.Css.clear).toHaveBeenCalledTimes(1); |
||||
|
}); |
||||
|
}); |
||||
Loading…
Reference in new issue