| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /**
- * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- /* global document */
- import ClassicTestEditor from '../_utils/classictesteditor';
- import testUtils from '../_utils/utils';
- import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
- import IndentEditing from '../../src/indent/indentediting';
- import IndentUI from '../../src/indent/indentui';
- describe( 'IndentUI', () => {
- let editor, element;
- testUtils.createSinonSandbox();
- beforeEach( () => {
- element = document.createElement( 'div' );
- document.body.appendChild( element );
- return ClassicTestEditor
- .create( element, { plugins: [ IndentUI, IndentEditing ] } )
- .then( newEditor => {
- editor = newEditor;
- } );
- } );
- afterEach( () => {
- element.remove();
- if ( editor ) {
- return editor.destroy();
- }
- } );
- it( 'should be named', () => {
- expect( IndentUI.pluginName ).to.equal( 'IndentUI' );
- } );
- it( 'should be loaded', () => {
- expect( editor.plugins.get( IndentUI ) ).to.be.instanceOf( IndentUI );
- } );
- it( 'should set up button for indent', () => {
- const indentButton = editor.ui.componentFactory.create( 'indent' );
- expect( indentButton ).to.be.instanceOf( ButtonView );
- } );
- it( 'should set up button for indent', () => {
- const outdentButton = editor.ui.componentFactory.create( 'outdent' );
- expect( outdentButton ).to.be.instanceOf( ButtonView );
- } );
- it( 'should execute indent command on button execute', () => {
- const button = editor.ui.componentFactory.create( 'indent' );
- const spy = sinon.spy( editor, 'execute' );
- button.fire( 'execute' );
- sinon.assert.calledOnce( spy );
- sinon.assert.calledWithExactly( spy, 'indent' );
- } );
- it( 'should execute outdent command on button execute', () => {
- const button = editor.ui.componentFactory.create( 'outdent' );
- const spy = sinon.spy( editor, 'execute' );
- button.fire( 'execute' );
- sinon.assert.calledOnce( spy );
- sinon.assert.calledWithExactly( spy, 'outdent' );
- } );
- } );
|