-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from ckeditor/i/104
Feature: Added support for running automated tests for TypeScript. Closes #104.
- Loading branch information
Showing
13 changed files
with
156 additions
and
23 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/ckeditor5-package-generator/lib/templates/ts/tests/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect } from 'chai'; | ||
import { MyPlugin as MyPluginDll, icons } from '../src'; | ||
import MyPlugin from '../src/myplugin'; | ||
|
||
import ckeditor from './../theme/icons/ckeditor.svg'; | ||
|
||
describe( 'CKEditor5 MyPlugin DLL', () => { | ||
it( 'exports MyPlugin', () => { | ||
expect( MyPluginDll ).to.equal( MyPlugin ); | ||
} ); | ||
|
||
describe( 'icons', () => { | ||
it( 'exports the "ckeditor" icon', () => { | ||
expect( icons.ckeditor ).to.equal( ckeditor ); | ||
} ); | ||
} ); | ||
} ); |
63 changes: 63 additions & 0 deletions
63
packages/ckeditor5-package-generator/lib/templates/ts/tests/myplugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { expect } from 'chai'; | ||
import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials'; | ||
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; | ||
import Heading from '@ckeditor/ckeditor5-heading/src/heading'; | ||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
import MyPlugin from '../src/myplugin'; | ||
|
||
import type { EditorWithUI } from 'ckeditor__ckeditor5-core/src/editor/editorwithui'; | ||
import type { DataApi } from 'ckeditor__ckeditor5-core/src/editor/utils/dataapimixin'; | ||
|
||
interface Editor extends EditorWithUI, DataApi {} | ||
|
||
describe( 'MyPlugin', () => { | ||
it( 'should be named', () => { | ||
expect( MyPlugin.pluginName ).to.equal( 'MyPlugin' ); | ||
} ); | ||
|
||
describe( 'init()', () => { | ||
let domElement: HTMLElement, editor: Editor; | ||
|
||
beforeEach( async () => { | ||
domElement = document.createElement( 'div' ); | ||
document.body.appendChild( domElement ); | ||
|
||
editor = await ClassicEditor.create( domElement, { | ||
plugins: [ | ||
Paragraph, | ||
Heading, | ||
Essentials, | ||
MyPlugin | ||
], | ||
toolbar: [ | ||
'myButton' | ||
] | ||
} ); | ||
} ); | ||
|
||
afterEach( () => { | ||
domElement.remove(); | ||
return editor.destroy(); | ||
} ); | ||
|
||
it( 'should load MyPlugin', () => { | ||
const myPlugin = editor.plugins.get( 'MyPlugin' ); | ||
|
||
expect( myPlugin ).to.be.an.instanceof( MyPlugin ); | ||
} ); | ||
|
||
it( 'should add an icon to the toolbar', () => { | ||
expect( editor.ui.componentFactory.has( 'myButton' ) ).to.equal( true ); | ||
} ); | ||
|
||
it( 'should add a text into the editor after clicking the icon', () => { | ||
const icon = editor.ui.componentFactory.create( 'myButton' ); | ||
|
||
expect( editor.getData() ).to.equal( '' ); | ||
|
||
icon.fire( 'execute' ); | ||
|
||
expect( editor.getData() ).to.equal( '<p>Hello CKEditor 5!</p>' ); | ||
} ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters