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

Tests: Basic styles normalization tests added.

Krzysztof Krztoń 7 лет назад
Родитель
Сommit
e365d050ec

+ 3 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/bold-within-text/normalized.word2016.html

@@ -0,0 +1,3 @@
+<p class=MsoNormal>
+	<span lang=PL style='mso-ansi-language:PL'>Some text <b style='mso-bidi-font-weight:normal'>with bold</b>.<o:p></o:p></span>
+</p>

+ 4 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/italic-starting-text/normalized.word2016.html

@@ -0,0 +1,4 @@
+<p class=MsoNormal>
+	<i style='mso-bidi-font-style:normal'><span lang=PL style='mso-ansi-language:PL'>Italic</span></i>
+	<span lang=PL style='mso-ansi-language:PL'> text.<o:p></o:p></span>
+</p>

+ 9 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/multiple-styles-multiline/normalized.word2016.html

@@ -0,0 +1,9 @@
+<p class=MsoNormal>
+	<span lang=PL style='mso-ansi-language:PL'>Line <b style='mso-bidi-font-weight:normal'>bold</b> and <i style='mso-bidi-font-style:normal'>italics</i><o:p></o:p></span>
+</p>
+
+<p class=MsoNormal>
+	<span lang=PL style='mso-ansi-language:PL'>Line <b style='mso-bidi-font-weight:normal'><u>foo</u></b><u> bar</u><o:p></o:p></span>
+</p>
+
+<p class=MsoNormal><s>Third</s> line <b style='mso-bidi-font-weight:normal'>styling, <i style='mso-bidi-font-style:normal'>space on e</i>nd&nbsp;</b><o:p></o:p></p>

+ 3 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/multiple-styles-single-line/normalized.word2016.html

@@ -0,0 +1,3 @@
+<p class=MsoNormal>
+	<span lang=PL style='mso-ansi-language:PL'>Text <b style='mso-bidi-font-weight:normal'><u>containi<s>ng</s></u></b><s><u> multi</u>ple </s><i style='mso-bidi-font-style:normal'>styling</i>.<o:p></o:p></span>
+</p>

+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/strikethrough-ending-text/normalized.word2016.html

@@ -0,0 +1 @@
+<p class=MsoNormal><span lang=PL style='mso-ansi-language:PL'>Text <s>incorrect</s><o:p></o:p></span></p>

+ 3 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/underlined-text/normalized.word2016.html

@@ -0,0 +1,3 @@
+<p class=MsoNormal>
+	<u><span lang=PL style='mso-ansi-language:PL'>Whole text underlined<o:p></o:p></span></u>
+</p>

+ 70 - 0
packages/ckeditor5-paste-from-office/tests/data/normalization/basic-styles.js

@@ -0,0 +1,70 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
+import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
+import PasteFromOffice from '../../../src/pastefromoffice';
+
+import { expectNormalized } from '../../_utils/utils';
+
+import boldWithinText from '../../_data/basic-styles/bold-within-text/input.word2016.html';
+import italicStartingText from '../../_data/basic-styles/italic-starting-text/input.word2016.html';
+import underlinedText from '../../_data/basic-styles/underlined-text/input.word2016.html';
+import strikethroughEndingText from '../../_data/basic-styles/strikethrough-ending-text/input.word2016.html';
+import multipleStylesSingleLine from '../../_data/basic-styles/multiple-styles-single-line/input.word2016.html';
+import multipleStylesMultiline from '../../_data/basic-styles/multiple-styles-multiline/input.word2016.html';
+
+import boldWithinTextNormalized from '../../_data/basic-styles/bold-within-text/normalized.word2016.html';
+import italicStartingTextNormalized from '../../_data/basic-styles/italic-starting-text/normalized.word2016.html';
+import underlinedTextNormalized from '../../_data/basic-styles/underlined-text/normalized.word2016.html';
+import strikethroughEndingTextNormalized from '../../_data/basic-styles/strikethrough-ending-text/normalized.word2016.html';
+import multipleStylesSingleLineNormalized from '../../_data/basic-styles/multiple-styles-single-line/normalized.word2016.html';
+import multipleStylesMultilineNormalized from '../../_data/basic-styles/multiple-styles-multiline/normalized.word2016.html';
+
+describe( 'Basic Styles – normalization', () => {
+	let editor, pasteFromOfficePlugin;
+
+	beforeEach( () => {
+		return VirtualTestEditor
+			.create( {
+				plugins: [ Clipboard, PasteFromOffice ]
+			} )
+			.then( newEditor => {
+				editor = newEditor;
+
+				pasteFromOfficePlugin = editor.plugins.get( 'PasteFromOffice' );
+			} );
+	} );
+
+	it( 'normalizes bold within text', () => {
+		expectNormalized(
+			pasteFromOfficePlugin._normalizeWordInput( boldWithinText, editor ), boldWithinTextNormalized );
+	} );
+
+	it( 'normalizes italic starting text', () => {
+		expectNormalized(
+			pasteFromOfficePlugin._normalizeWordInput( italicStartingText, editor ), italicStartingTextNormalized );
+	} );
+
+	it( 'normalizes underlined text', () => {
+		expectNormalized(
+			pasteFromOfficePlugin._normalizeWordInput( underlinedText, editor ), underlinedTextNormalized );
+	} );
+
+	it( 'normalizes strikethrough ending text', () => {
+		expectNormalized(
+			pasteFromOfficePlugin._normalizeWordInput( strikethroughEndingText, editor ), strikethroughEndingTextNormalized );
+	} );
+
+	it( 'normalizes mulitple styles single line', () => {
+		expectNormalized(
+			pasteFromOfficePlugin._normalizeWordInput( multipleStylesSingleLine, editor ), multipleStylesSingleLineNormalized );
+	} );
+
+	it( 'normalizes mulitple styles multiline', () => {
+		expectNormalized(
+			pasteFromOfficePlugin._normalizeWordInput( multipleStylesMultiline, editor ), multipleStylesMultilineNormalized );
+	} );
+} );