import { describe, expect, it, beforeEach, afterEach } from 'vitest'; import { ClassicEditor, Essentials, Paragraph, Heading } from 'ckeditor5'; import Import from '../src/import.js'; describe( 'Import', () => { it( 'should be named', () => { expect( Import.pluginName ).to.equal( 'Import' ); } ); 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, Import ], toolbar: [ 'importButton' ] } ); } ); afterEach( () => { domElement.remove(); return editor.destroy(); } ); it( 'should load Import', () => { const myPlugin = editor.plugins.get( 'Import' ); expect( myPlugin ).to.be.an.instanceof( Import ); } ); it( 'should add an icon to the toolbar', () => { expect( editor.ui.componentFactory.has( 'importButton' ) ).to.equal( true ); } ); it( 'should add a text into the editor after clicking the icon', () => { const icon = editor.ui.componentFactory.create( 'importButton' ); expect( editor.getData() ).to.equal( '' ); icon.fire( 'execute' ); expect( editor.getData() ).to.equal( '

Hello CKEditor 5!

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