|
|
@@ -0,0 +1,62 @@
|
|
|
+/**
|
|
|
+ * @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 Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
+import UndoEditing from '@ckeditor/ckeditor5-undo/src/undoediting';
|
|
|
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
|
|
|
+
|
|
|
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
+
|
|
|
+import TextTransformation from '../src/texttransformation';
|
|
|
+
|
|
|
+describe( 'Text transformation feature - integration', () => {
|
|
|
+ let editorElement, editor, model, doc;
|
|
|
+
|
|
|
+ testUtils.createSinonSandbox();
|
|
|
+
|
|
|
+ beforeEach( () => {
|
|
|
+ editorElement = document.createElement( 'div' );
|
|
|
+ document.body.appendChild( editorElement );
|
|
|
+ } );
|
|
|
+
|
|
|
+ afterEach( () => {
|
|
|
+ editorElement.remove();
|
|
|
+
|
|
|
+ return editor.destroy();
|
|
|
+ } );
|
|
|
+
|
|
|
+ describe( 'with undo', () => {
|
|
|
+ beforeEach( () => {
|
|
|
+ return ClassicTestEditor
|
|
|
+ .create( editorElement, { plugins: [ Paragraph, TextTransformation, UndoEditing ] } )
|
|
|
+ .then( newEditor => {
|
|
|
+ editor = newEditor;
|
|
|
+ model = editor.model;
|
|
|
+ doc = model.document;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should undo text transformation', () => {
|
|
|
+ editor.setData( '<p>foo</p>' );
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( doc.getRoot().getChild( 0 ), 'end' );
|
|
|
+ writer.insertText( '(tm)', doc.selection.getFirstPosition() );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.getData() ).to.equal( '<p>foo™</p>' );
|
|
|
+
|
|
|
+ editor.execute( 'undo' );
|
|
|
+
|
|
|
+ expect( editor.getData() ).to.equal( '<p>foo(tm)</p>' );
|
|
|
+
|
|
|
+ editor.execute( 'redo' );
|
|
|
+
|
|
|
+ expect( editor.getData() ).to.equal( '<p>foo™</p>' );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+} );
|