8
0
Просмотр исходного кода

Added manual and automated test.

Piotrek Koszuliński 9 лет назад
Родитель
Сommit
a92c3ef9c0

+ 7 - 0
packages/ckeditor5-typing/tests/tickets/59/1.html

@@ -0,0 +1,7 @@
+<head>
+	<link rel="stylesheet" href="%APPS_DIR%ckeditor/build/modules/amd/theme/ckeditor.css">
+</head>
+
+<div id="editor">
+	<p><strong>This</strong> is an editor <strong>instance</strong>.</p>
+</div>

+ 22 - 0
packages/ckeditor5-typing/tests/tickets/59/1.js

@@ -0,0 +1,22 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals console, document, window */
+
+import ClassicEditor from '/ckeditor5/editor-classic/classic.js';
+import Typing from '/ckeditor5/typing/typing.js';
+import Paragraph from '/ckeditor5/paragraph/paragraph.js';
+import Bold from '/ckeditor5/basic-styles/bold.js';
+
+ClassicEditor.create( document.querySelector( '#editor' ), {
+	features: [ Typing, Paragraph, Bold ],
+	toolbar: [ 'bold' ]
+} )
+.then( editor => {
+	window.editor = editor;
+} )
+.catch( err => {
+	console.error( err.stack );
+} );

+ 8 - 0
packages/ckeditor5-typing/tests/tickets/59/1.md

@@ -0,0 +1,8 @@
+@bender-ui: collapsed
+@bender-tags: ticket, 59, iteration4
+
+### Issue [#59](https://github.com/ckeditor/ckeditor5-typing/issues/59) manual test
+
+1. Put selection at the end of the text.
+2. Start backspacing.
+3. No error should be thrown.

+ 41 - 0
packages/ckeditor5-typing/tests/tickets/59/2.js

@@ -0,0 +1,41 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals document */
+
+import ClassicEditor from '/ckeditor5/editor-classic/classic.js';
+import Typing from '/ckeditor5/typing/typing.js';
+import Paragraph from '/ckeditor5/paragraph/paragraph.js';
+import Bold from '/ckeditor5/basic-styles/bold.js';
+import { setData } from '/ckeditor5/engine/dev-utils/model.js';
+
+describe( 'Bug #59', () => {
+	let editor;
+	let container;
+
+	beforeEach( () => {
+		container = document.createElement( 'div' );
+		document.body.appendChild( container );
+
+		return ClassicEditor.create( container, {
+			features: [ Typing, Paragraph, Bold ]
+		} )
+		.then( newEditor => {
+			editor = newEditor;
+		} );
+	} );
+
+	it( 'editor does not blow up when deleting last styled character', () => {
+		editor.document.enqueueChanges( () => {
+			setData( editor.document, '<paragraph><$text bold="true">foo</$text> x <$text bold="true">bar</$text>.[]</paragraph>' );
+		} );
+
+		while ( editor.document.selection.anchor.offset > 0 ) {
+			editor.execute( 'delete' );
+		}
+
+		expect( editor.getData() ).to.equal( '<p>&nbsp;</p>' );
+	} );
+} );