mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
chore(ckeditor5-math): initialize empty plugin
This commit is contained in:
56
packages/ckeditor5-math/tests/math.ts
Normal file
56
packages/ckeditor5-math/tests/math.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { describe, expect, it, beforeEach, afterEach } from 'vitest';
|
||||
import { ClassicEditor, Essentials, Paragraph, Heading } from 'ckeditor5';
|
||||
import Math from '../src/math.js';
|
||||
|
||||
describe( 'Math', () => {
|
||||
it( 'should be named', () => {
|
||||
expect( Math.pluginName ).to.equal( 'Math' );
|
||||
} );
|
||||
|
||||
describe( 'init()', () => {
|
||||
let domElement: HTMLElement, editor: ClassicEditor;
|
||||
|
||||
beforeEach( async () => {
|
||||
domElement = document.createElement( 'div' );
|
||||
document.body.appendChild( domElement );
|
||||
|
||||
editor = await ClassicEditor.create( domElement, {
|
||||
licenseKey: 'GPL',
|
||||
plugins: [
|
||||
Paragraph,
|
||||
Heading,
|
||||
Essentials,
|
||||
Math
|
||||
],
|
||||
toolbar: [
|
||||
'math'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
afterEach( () => {
|
||||
domElement.remove();
|
||||
return editor.destroy();
|
||||
} );
|
||||
|
||||
it( 'should load Math', () => {
|
||||
const myPlugin = editor.plugins.get( 'Math' );
|
||||
|
||||
expect( myPlugin ).to.be.an.instanceof( Math );
|
||||
} );
|
||||
|
||||
it( 'should add an icon to the toolbar', () => {
|
||||
expect( editor.ui.componentFactory.has( 'math' ) ).to.equal( true );
|
||||
} );
|
||||
|
||||
it( 'should add a text into the editor after clicking the icon', () => {
|
||||
const icon = editor.ui.componentFactory.create( 'math' );
|
||||
|
||||
expect( editor.getData() ).to.equal( '' );
|
||||
|
||||
icon.fire( 'execute' );
|
||||
|
||||
expect( editor.getData() ).to.equal( '<p>Hello CKEditor 5!</p>' );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
Reference in New Issue
Block a user