This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
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.
Added tests for TodoList and TodoListUI plugins.
- Loading branch information
1 parent
9353588
commit 0d448f1
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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,18 @@ | ||
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
import TodoList from '../src/todolist'; | ||
import TodoListEditing from '../src/todolistediting'; | ||
import TodoListUI from '../src/todolistui'; | ||
|
||
describe( 'TodoList', () => { | ||
it( 'should be named', () => { | ||
expect( TodoList.pluginName ).to.equal( 'TodoList' ); | ||
} ); | ||
|
||
it( 'should require TodoListEditing and TodoListUI', () => { | ||
expect( TodoList.requires ).to.deep.equal( [ TodoListEditing, TodoListUI ] ); | ||
} ); | ||
} ); |
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,61 @@ | ||
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/* globals document */ | ||
|
||
import TodoListEditing from '../src/todolistediting'; | ||
import TodoListUI from '../src/todolistui'; | ||
|
||
import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor'; | ||
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; | ||
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; | ||
import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; | ||
|
||
describe( 'TodoListUI', () => { | ||
let editor, model, button; | ||
|
||
beforeEach( () => { | ||
const editorElement = document.createElement( 'div' ); | ||
document.body.appendChild( editorElement ); | ||
|
||
return ClassicTestEditor.create( editorElement, { plugins: [ Paragraph, TodoListEditing, TodoListUI ] } ) | ||
.then( newEditor => { | ||
editor = newEditor; | ||
model = editor.model; | ||
|
||
button = editor.ui.componentFactory.create( 'todoList' ); | ||
} ); | ||
} ); | ||
|
||
afterEach( () => { | ||
return editor.destroy(); | ||
} ); | ||
|
||
it( 'should set up buttons for bulleted list and numbered list', () => { | ||
expect( button ).to.be.instanceOf( ButtonView ); | ||
} ); | ||
|
||
it( 'should execute proper commands when buttons are used', () => { | ||
sinon.spy( editor, 'execute' ); | ||
|
||
button.fire( 'execute' ); | ||
sinon.assert.calledWithExactly( editor.execute, 'todoList' ); | ||
} ); | ||
|
||
it( 'should bind button to command', () => { | ||
setData( model, '<listItem listType="todo" listIndent="0">[]foo</listItem>' ); | ||
|
||
const command = editor.commands.get( 'todoList' ); | ||
|
||
expect( button.isOn ).to.be.true; | ||
expect( button.isEnabled ).to.be.true; | ||
|
||
command.value = false; | ||
expect( button.isOn ).to.be.false; | ||
|
||
command.isEnabled = false; | ||
expect( button.isEnabled ).to.be.false; | ||
} ); | ||
} ); |