8
0
Эх сурвалжийг харах

Tests: Link normalization tests added.

Krzysztof Krztoń 7 жил өмнө
parent
commit
b9c0a8066e

+ 3 - 0
packages/ckeditor5-paste-from-office/tests/_data/link/combined/normalized.word2016.html

@@ -0,0 +1,3 @@
+<p class=MsoNormal>
+	<span lang=PL style='mso-ansi-language:PL'><a href="https://ckeditor.com/">CKEditor</a><a href="https://cksource.com/">CKSource</a> 2<o:p></o:p></span>
+</p>

+ 5 - 0
packages/ckeditor5-paste-from-office/tests/_data/link/two-line/normalized.word2016.html

@@ -0,0 +1,5 @@
+<p class=MsoNormal>
+	<span lang=PL style='mso-ansi-language:PL'>
+		<a href="https://cksource.com/">Long link <br> WITH spaces</a><o:p></o:p>
+	</span>
+</p>

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

@@ -0,0 +1,3 @@
+<p class=MsoNormal>
+	<span lang=PL style='mso-ansi-language:PL'>Regular <a href="https://ckeditor.com/">link</a>1<o:p></o:p></span>
+</p>

+ 46 - 0
packages/ckeditor5-paste-from-office/tests/data/normalization/link.js

@@ -0,0 +1,46 @@
+/**
+ * @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 withinText from '../../_data/link/within-text/input.word2016.html';
+import combined from '../../_data/link/combined/input.word2016.html';
+import twoLine from '../../_data/link/two-line/input.word2016.html';
+
+import withinTextNormalized from '../../_data/link/within-text/normalized.word2016.html';
+import combinedNormalized from '../../_data/link/combined/normalized.word2016.html';
+import twoLineNormalized from '../../_data/link/two-line/normalized.word2016.html';
+
+describe( 'Link – normalization', () => {
+	let editor, pasteFromOfficePlugin;
+
+	beforeEach( () => {
+		return VirtualTestEditor
+			.create( {
+				plugins: [ Clipboard, PasteFromOffice ]
+			} )
+			.then( newEditor => {
+				editor = newEditor;
+
+				pasteFromOfficePlugin = editor.plugins.get( 'PasteFromOffice' );
+			} );
+	} );
+
+	it( 'normalizes link within text', () => {
+		expectNormalized( pasteFromOfficePlugin._normalizeWordInput( withinText, editor ), withinTextNormalized );
+	} );
+
+	it( 'normalizes combined links', () => {
+		expectNormalized( pasteFromOfficePlugin._normalizeWordInput( combined, editor ), combinedNormalized );
+	} );
+
+	it( 'normalizes two line links', () => {
+		expectNormalized( pasteFromOfficePlugin._normalizeWordInput( twoLine, editor ), twoLineNormalized );
+	} );
+} );