chore(ckeditor5-math): integrate tests partially

This commit is contained in:
Elian Doran 2025-05-04 22:50:18 +03:00
parent 5d42b942ba
commit e85e92e074
No known key found for this signature in database
10 changed files with 952 additions and 194 deletions

View File

@ -1,14 +0,0 @@
import { Math as MathDll, AutoformatMath as AutoformatMathDll } from '../src';
import Math from '../src/math';
import AutoformatMath from '../src/autoformatmath';
import { expect } from 'chai';
describe( 'CKEditor5 Math DLL', () => {
it( 'exports Math', () => {
expect( MathDll ).to.equal( Math );
} );
it( 'exports AutoformatMath', () => {
expect( AutoformatMathDll ).to.equal( AutoformatMath );
} );
} );

View File

@ -1,55 +0,0 @@
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import Mathematics from '../src/math';
import MathEditing from '../src/mathediting';
import MathUI from '../src/mathui';
import AutoMath from '../src/automath';
import Widget from '@ckeditor/ckeditor5-widget/src/widget';
import global from '@ckeditor/ckeditor5-utils/src/dom/global';
import { expect } from 'chai';
describe( 'Math', () => {
let editorElement: HTMLDivElement, editor: ClassicEditor;
beforeEach( async () => {
editorElement = document.createElement( 'div' );
document.body.appendChild( editorElement );
return ClassicEditor
.create( editorElement, {
plugins: [ Mathematics ]
} )
.then( newEditor => {
editor = newEditor;
} );
} );
afterEach( () => {
editorElement.remove();
return editor.destroy();
} );
it( 'should be loaded', () => {
expect( editor.plugins.get( Mathematics ) ).to.instanceOf( Mathematics );
} );
it( 'should load MathEditing plugin', () => {
expect( editor.plugins.get( MathEditing ) ).to.instanceOf( MathEditing );
} );
it( 'should load Widget plugin', () => {
expect( editor.plugins.get( Widget ) ).to.instanceOf( Widget );
} );
it( 'should load MathUI plugin', () => {
expect( editor.plugins.get( MathUI ) ).to.instanceOf( MathUI );
} );
it( 'should load AutoMath plugin', () => {
expect( editor.plugins.get( AutoMath ) ).to.instanceOf( AutoMath );
} );
it( 'has proper name', () => {
expect( Mathematics.pluginName ).to.equal( 'Math' );
} );
} );

View File

@ -36,6 +36,7 @@
],
"devDependencies": {
"@ckeditor/ckeditor5-dev-build-tools": "43.0.1",
"@ckeditor/ckeditor5-dev-utils": "43.0.1",
"@ckeditor/ckeditor5-inspector": ">=4.1.0",
"@ckeditor/ckeditor5-package-tools": "^3.0.1",
"@typescript-eslint/eslint-plugin": "~5.43.0",
@ -49,6 +50,7 @@
"http-server": "^14.1.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.6",
"sinon": "20.0.0",
"stylelint": "^13.13.1",
"stylelint-config-ckeditor5": ">=9.1.0",
"ts-node": "^10.9.1",

View File

@ -1,14 +1,9 @@
import Mathematics from '../src/math';
import AutoMath from '../src/automath';
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import Undo from '@ckeditor/ckeditor5-undo/src/undo';
import Typing from '@ckeditor/ckeditor5-typing/src/typing';
import global from '@ckeditor/ckeditor5-utils/src/dom/global';
import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
import Mathematics from '../src/math.js';
import AutoMath from '../src/automath.js';
import { ClassicEditor, Clipboard, Paragraph, Undo, Typing, getData, setData } from 'ckeditor5';
import { expect } from 'chai';
import type { SinonFakeTimers } from 'sinon';
import { describe, beforeEach, it, afterEach } from "vitest";
describe( 'AutoMath - integration', () => {
let editorElement: HTMLDivElement, editor: ClassicEditor;

View File

@ -1,17 +1,14 @@
import { describe, expect, it } from 'vitest';
import { Math as MathDll, icons } from '../src/index.js';
import Math from '../src/math.js';
import ckeditor from './../theme/icons/ckeditor.svg';
import { Math as MathDll, AutoformatMath as AutoformatMathDll } from '../src';
import Math from '../src/math';
import AutoformatMath from '../src/autoformatmath';
import { expect } from 'chai';
describe( 'CKEditor5 Math DLL', () => {
it( 'exports Math', () => {
expect( MathDll ).to.equal( Math );
} );
describe( 'icons', () => {
it( 'exports the "ckeditor" icon', () => {
expect( icons.ckeditor ).to.equal( ckeditor );
} );
it( 'exports AutoformatMath', () => {
expect( AutoformatMathDll ).to.equal( AutoformatMath );
} );
} );

View File

@ -1,7 +1,7 @@
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import { ClassicEditor, type EditorConfig } from 'ckeditor5';
import MathUI from '../src/mathui';
import type { EditorConfig } from '@ckeditor/ckeditor5-core/src/editor/editorconfig';
import { expect } from 'chai';
import { describe, beforeEach, it, afterEach } from "vitest";
describe( 'Lazy load', () => {
let editorElement: HTMLDivElement;

View File

@ -1,56 +1,54 @@
import { describe, expect, it, beforeEach, afterEach } from 'vitest';
import { ClassicEditor, Essentials, Paragraph, Heading } from 'ckeditor5';
import Math from '../src/math.js';
import { ClassicEditor, Widget } from 'ckeditor5';
import Mathematics from '../src/math.js';
import MathEditing from '../src/mathediting.js';
import MathUI from '../src/mathui.js';
import AutoMath from '../src/automath.js';
import { expect } from 'chai';
import { describe, beforeEach, it, afterEach } from "vitest";
describe( 'Math', () => {
it( 'should be named', () => {
expect( Math.pluginName ).to.equal( 'Math' );
} );
describe( 'init()', () => {
let domElement: HTMLElement, editor: ClassicEditor;
let editorElement: HTMLDivElement, editor: ClassicEditor;
beforeEach( async () => {
domElement = document.createElement( 'div' );
document.body.appendChild( domElement );
editorElement = document.createElement( 'div' );
document.body.appendChild( editorElement );
editor = await ClassicEditor.create( domElement, {
licenseKey: 'GPL',
plugins: [
Paragraph,
Heading,
Essentials,
Math
],
toolbar: [
'math'
]
return ClassicEditor
.create( editorElement, {
plugins: [ Mathematics ]
} )
.then( newEditor => {
editor = newEditor;
} );
} );
afterEach( () => {
domElement.remove();
editorElement.remove();
return editor.destroy();
} );
it( 'should load Math', () => {
const myPlugin = editor.plugins.get( 'Math' );
expect( myPlugin ).to.be.an.instanceof( Math );
it( 'should be loaded', () => {
expect( editor.plugins.get( Mathematics ) ).to.instanceOf( Mathematics );
} );
it( 'should add an icon to the toolbar', () => {
expect( editor.ui.componentFactory.has( 'math' ) ).to.equal( true );
it( 'should load MathEditing plugin', () => {
expect( editor.plugins.get( MathEditing ) ).to.instanceOf( MathEditing );
} );
it( 'should add a text into the editor after clicking the icon', () => {
const icon = editor.ui.componentFactory.create( 'math' );
it( 'should load Widget plugin', () => {
expect( editor.plugins.get( Widget ) ).to.instanceOf( Widget );
} );
expect( editor.getData() ).to.equal( '' );
it( 'should load MathUI plugin', () => {
expect( editor.plugins.get( MathUI ) ).to.instanceOf( MathUI );
} );
icon.fire( 'execute' );
it( 'should load AutoMath plugin', () => {
expect( editor.plugins.get( AutoMath ) ).to.instanceOf( AutoMath );
} );
expect( editor.getData() ).to.equal( '<p>Hello CKEditor 5!</p>' );
} );
it( 'has proper name', () => {
expect( Mathematics.pluginName ).to.equal( 'Math' );
} );
} );

View File

@ -1,20 +1,15 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* globals document, Event */
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor.js';
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard.js';
import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
import MathUI from '../src/mathui';
import MainFormView from '../src/ui/mainformview';
import ContextualBalloon from '@ckeditor/ckeditor5-ui/src/panel/balloon/contextualballoon.js';
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview.js';
import View from '@ckeditor/ckeditor5-ui/src/view.js';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
import { ClassicEditor, ContextualBalloon, ButtonView, View, Paragraph, ClickObserver, keyCodes } from 'ckeditor5';
import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobserver.js';
import { expect } from 'chai';
import type { SinonSpy } from 'sinon';
import { describe, beforeEach, it, afterEach } from "vitest";
describe( 'MathUI', () => {
let editorElement: HTMLDivElement;

950
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff