import { describe, expect, it, beforeEach, afterEach } from 'vitest'; import { ClassicEditor, Essentials, Paragraph, Heading } from 'ckeditor5'; import Export from '../src/export.js'; describe( 'Export', () => { it( 'should be named', () => { expect( Export.pluginName ).to.equal( 'Export' ); } ); describe( 'init()', () => { let domElement: HTMLElement, editor: ClassicEditor; beforeEach( async () => { domElement = document.createElement( 'div' ); document.body.appendChild( domElement ); editor = await ClassicEditor.create( domElement, { plugins: [ Paragraph, Heading, Essentials, Export ], toolbar: [ 'exportButton' ] } ); } ); afterEach( () => { domElement.remove(); return editor.destroy(); } ); it( 'should load Export', () => { const myPlugin = editor.plugins.get( 'Export' ); expect( myPlugin ).to.be.an.instanceof( Export ); } ); it( 'should add an icon to the toolbar', () => { expect( editor.ui.componentFactory.has( 'exportButton' ) ).to.equal( true ); } ); it( 'should add a text into the editor after clicking the icon', () => { const icon = editor.ui.componentFactory.create( 'exportButton' ); expect( editor.getData() ).to.equal( '' ); icon.fire( 'execute' ); expect( editor.getData() ).to.equal( '

Hello CKEditor 5!

' ); } ); } ); } );