瀏覽代碼

Tests: Refactoring basic styles tests and utils.

Krzysztof Krztoń 7 年之前
父節點
當前提交
03ef9ae402

File diff suppressed because it is too large
+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/bold-within-text/normalized.safari.word2016.html


+ 21 - 6
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/index.js

@@ -28,12 +28,12 @@ export const fixtures = {
 		multipleStylesMultiline
 	},
 	normalized: {
-		boldWithinTextNormalized,
-		italicStartingTextNormalized,
-		underlinedTextNormalized,
-		strikethroughEndingTextNormalized,
-		multipleStylesSingleLineNormalized,
-		multipleStylesMultilineNormalized
+		boldWithinText: boldWithinTextNormalized,
+		italicStartingText: italicStartingTextNormalized,
+		underlinedText: underlinedTextNormalized,
+		strikethroughEndingText: strikethroughEndingTextNormalized,
+		multipleStylesSingleLine: multipleStylesSingleLineNormalized,
+		multipleStylesMultiline: multipleStylesMultilineNormalized
 	}
 };
 
@@ -45,6 +45,13 @@ import strikethroughEndingTextSafari from './strikethrough-ending-text/input.saf
 import multipleStylesSingleLineSafari from './multiple-styles-single-line/input.safari.word2016.html';
 import multipleStylesMultilineSafari from './multiple-styles-multiline/input.safari.word2016.html';
 
+import boldWithinTextNormalizedSafari from './bold-within-text/normalized.safari.word2016.html';
+import italicStartingTextNormalizedSafari from './italic-starting-text/normalized.safari.word2016.html';
+import underlinedTextNormalizedSafari from './underlined-text/normalized.safari.word2016.html';
+import strikethroughEndingTextNormalizedSafari from './strikethrough-ending-text/normalized.safari.word2016.html';
+import multipleStylesSingleLineNormalizedSafari from './multiple-styles-single-line/normalized.safari.word2016.html';
+import multipleStylesMultilineNormalizedSafari from './multiple-styles-multiline/normalized.safari.word2016.html';
+
 export const browserFixtures = {
 	safari: {
 		input: {
@@ -54,6 +61,14 @@ export const browserFixtures = {
 			strikethroughEndingText: strikethroughEndingTextSafari,
 			multipleStylesSingleLine: multipleStylesSingleLineSafari,
 			multipleStylesMultiline: multipleStylesMultilineSafari
+		},
+		normalized: {
+			boldWithinText: boldWithinTextNormalizedSafari,
+			italicStartingText: italicStartingTextNormalizedSafari,
+			underlinedText: underlinedTextNormalizedSafari,
+			strikethroughEndingText: strikethroughEndingTextNormalizedSafari,
+			multipleStylesSingleLine: multipleStylesSingleLineNormalizedSafari,
+			multipleStylesMultiline: multipleStylesMultilineNormalizedSafari
 		}
 	}
 };

File diff suppressed because it is too large
+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/italic-starting-text/normalized.safari.word2016.html


File diff suppressed because it is too large
+ 3 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/multiple-styles-multiline/normalized.safari.word2016.html


File diff suppressed because it is too large
+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/multiple-styles-single-line/normalized.safari.word2016.html


File diff suppressed because it is too large
+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/strikethrough-ending-text/normalized.safari.word2016.html


File diff suppressed because it is too large
+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/basic-styles/underlined-text/normalized.safari.word2016.html


+ 0 - 41
packages/ckeditor5-paste-from-office/tests/_utils/browser.js

@@ -1,41 +0,0 @@
-/**
- * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* global navigator */
-
-/**
- * Returns the name of the browser in which code is executed based on `window.navigator` object.
- *
- * @returns {String|null} Lowercase browser name or null if non-standard browser is used.
- */
-export function getBrowserName() {
-	const browsers = detectBrowsers( navigator );
-
-	const browser = Object.keys( browsers ).filter( browserName => !!browsers[ browserName ] );
-
-	return browser.length ? browser[ 0 ] : null;
-}
-
-// Checks if current browser is one of the predefined ones (Chrome, Edge, Firefox, IE, Safari).
-//
-// @param {Navigator} navigator Browser `window.navigator` object on which detection is based.
-// @returns {{chrome: Boolean, edge: Boolean, firefox: Boolean, ie: Boolean, safari: Boolean}}
-function detectBrowsers( navigator ) {
-	const agent = navigator.userAgent.toLowerCase();
-	const edge = agent.match( /edge[ /](\d+.?\d*)/ );
-	const trident = agent.indexOf( 'trident/' ) > -1;
-	const ie = !!( edge || trident );
-	const webkit = !ie && ( agent.indexOf( ' applewebkit/' ) > -1 );
-	const gecko = navigator.product === 'Gecko' && !webkit && !ie;
-	const chrome = webkit && agent.indexOf( 'chrome' ) > -1;
-
-	return {
-		chrome,
-		edge: !!edge,
-		firefox: gecko,
-		ie,
-		safari: webkit && !chrome,
-	};
-}

+ 6 - 3
packages/ckeditor5-paste-from-office/tests/_utils/fixtures.js

@@ -3,16 +3,19 @@
  * For licensing, see LICENSE.md.
  */
 
-import { getBrowserName } from './browser';
+import { getBrowserName } from './utils';
 
 import { fixtures as basicStyles, browserFixtures as basicStylesBrowser } from '../_data/basic-styles/index.js';
+import { fixtures as link, browserFixtures as linkBrowser } from '../_data/link/index.js';
 
 const fixtures = {
-	'basic-styles': basicStyles
+	'basic-styles': basicStyles,
+	link
 };
 
 const browserFixtures = {
-	'basic-styles': basicStylesBrowser
+	'basic-styles': basicStylesBrowser,
+	link: linkBrowser
 };
 
 export function getFixtures( group ) {

+ 67 - 1
packages/ckeditor5-paste-from-office/tests/_utils/utils.js

@@ -3,9 +3,11 @@
  * For licensing, see LICENSE.md.
  */
 
+/* global navigator */
+
 import normalizeHtml from '@ckeditor/ckeditor5-utils/tests/_utils/normalizehtml';
 
-import { getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+import { getData as getModelData, stringify as stringifyModel } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { stringify, getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
 /**
@@ -91,3 +93,67 @@ export function expectNormalized( actual, expected ) {
 
 	expect( actualNormalized ).to.equal( normalizeHtml( expectedInlined ) );
 }
+
+/**
+ * Compares two models string representations. This function hooks into {@link module:engine/model/model~Model#insertContent}
+ * to get the model representarion before it is inserted.
+ *
+ * @param {module:core/editor/editor~Editor} editor
+ * @param {String} input
+ * @param {String} expected
+ */
+export function expectModel( editor, input, expected ) {
+	const editorModel = editor.model;
+	const insertContent = editorModel.insertContent;
+
+	let actual = '';
+
+	sinon.stub( editorModel, 'insertContent' ).callsFake( ( content, selection ) => {
+		// Save model string representation now as it may change after `insertContent()` function call
+		// so accessing it later may not work as it may have empty/changed structure.
+		actual = stringifyModel( content );
+		insertContent.call( editorModel, content, selection );
+	} );
+
+	pasteHtml( editor, input );
+
+	sinon.restore();
+
+	expect( actual.replace( /\u00A0/g, '#' ).replace( / /g, '#' ) )
+		.to.equal( expected.replace( /\u00A0/g, '#' ).replace( / /g, '#' ) );
+}
+
+/**
+ * Returns the name of the browser in which code is executed based on `window.navigator` object.
+ *
+ * @returns {String|null} Lowercase browser name or null if non-standard browser is used.
+ */
+export function getBrowserName() {
+	const browsers = detectBrowsers( navigator );
+
+	const browser = Object.keys( browsers ).filter( browserName => !!browsers[ browserName ] );
+
+	return browser.length ? browser[ 0 ] : null;
+}
+
+// Checks if current browser is one of the predefined ones (Chrome, Edge, Firefox, IE, Safari).
+//
+// @param {Navigator} navigator Browser `window.navigator` object on which detection is based.
+// @returns {{chrome: Boolean, edge: Boolean, firefox: Boolean, ie: Boolean, safari: Boolean}}
+function detectBrowsers( navigator ) {
+	const agent = navigator.userAgent.toLowerCase();
+	const edge = agent.match( /edge[ /](\d+.?\d*)/ );
+	const trident = agent.indexOf( 'trident/' ) > -1;
+	const ie = !!( edge || trident );
+	const webkit = !ie && ( agent.indexOf( ' applewebkit/' ) > -1 );
+	const gecko = navigator.product === 'Gecko' && !webkit && !ie;
+	const chrome = webkit && agent.indexOf( 'chrome' ) > -1;
+
+	return {
+		chrome,
+		edge: !!edge,
+		firefox: gecko,
+		ie,
+		safari: webkit && !chrome,
+	};
+}

+ 43 - 224
packages/ckeditor5-paste-from-office/tests/data/integration/basic-styles.js

@@ -16,14 +16,14 @@ import Strikethrough from '@ckeditor/ckeditor5-basic-styles/src/strikethrough';
 import PasteFromOffice from '../../../src/pastefromoffice';
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
-import { expectPaste } from '../../_utils/utils';
 import { getFixtures } from '../../_utils/fixtures';
+import { expectModel } from '../../_utils/utils';
 
 describe( 'Basic Styles – integration', () => {
-	let element, editor, fixtures;
+	let element, editor, input;
 
 	before( () => {
-		fixtures = getFixtures( 'basic-styles' ).input;
+		input = getFixtures( 'basic-styles' ).input;
 
 		element = document.createElement( 'div' );
 
@@ -46,244 +46,63 @@ describe( 'Basic Styles – integration', () => {
 		element.remove();
 	} );
 
-	// Pastes: 'Some text <b>with bold</b>.'
-	// Input same for: Chrome, Firefox and Edge.
-	describe( 'bold within text', () => {
-		it( 'pastes in the empty editor', () => {
-			expectPaste( editor, fixtures.boldWithinText, '<paragraph>Some text <$text bold="true">with bold</$text>.[]</paragraph>' );
-		} );
-
-		it( 'pastes in the paragraph', () => {
-			setData( editor.model, '<paragraph>More [] text</paragraph>' );
-
-			expectPaste( editor, fixtures.boldWithinText,
-				'<paragraph>More Some text <$text bold="true">with bold</$text>.[] text</paragraph>' );
-		} );
-
-		it( 'pastes in the different block context', () => {
-			setData( editor.model, '<heading1>More [] text</heading1>' );
-
-			expectPaste( editor, fixtures.boldWithinText,
-				'<heading1>More Some text <$text bold="true">with bold</$text>.[] text</heading1>' );
-		} );
-
-		it( 'pastes in the inline styling context', () => {
-			setData( editor.model, '<paragraph><$text italic="true">Ita[]lic</$text></paragraph>' );
-
-			expectPaste( editor, fixtures.boldWithinText, '<paragraph><$text italic="true">Ita</$text>Some text ' +
-				'<$text bold="true">with bold</$text>.[]<$text italic="true">lic</$text></paragraph>' );
-		} );
-
-		it( 'pastes inside another bold element', () => {
-			setData( editor.model, '<paragraph><$text bold="true">Ita[]lic</$text></paragraph>' );
+	// Pastes:
+	//		<p>Some text <b>with bold</b>.</p>
+	it( 'pastes bold within text', () => {
+		const expected = '<paragraph>Some text <$text bold="true">with bold</$text>.</paragraph>';
 
-			expectPaste( editor, fixtures.boldWithinText, '<paragraph><$text bold="true">Ita</$text>Some text ' +
-				'<$text bold="true">with bold</$text>.[]<$text bold="true">lic</$text></paragraph>' );
-		} );
+		expectModel( editor, input.boldWithinText, expected );
 	} );
 
-	// Pastes: '<i>Italic</i> text.'
-	// Input same for: Chrome, Firefox and Edge.
-	describe( 'italic starting text', () => {
-		it( 'pastes in the empty editor', () => {
-			expectPaste( editor, fixtures.italicStartingText, '<paragraph><$text italic="true">Italic</$text> text.[]</paragraph>' );
-		} );
-
-		it( 'pastes in the paragraph', () => {
-			setData( editor.model, '<paragraph>More [] text</paragraph>' );
-
-			expectPaste( editor, fixtures.italicStartingText,
-				'<paragraph>More <$text italic="true">Italic</$text> text.[] text</paragraph>' );
-		} );
-
-		it( 'pastes in the different block context', () => {
-			setData( editor.model, '<heading1>More [] text</heading1>' );
-
-			expectPaste( editor, fixtures.italicStartingText,
-				'<heading1>More <$text italic="true">Italic</$text> text.[] text</heading1>' );
-		} );
-
-		it( 'pastes in the inline styling context', () => {
-			setData( editor.model, '<paragraph><$text bold="true">Bol[]d</$text></paragraph>' );
-
-			expectPaste( editor, fixtures.italicStartingText, '<paragraph><$text bold="true">Bol</$text><$text italic="true">' +
-				'Italic</$text> text.[]<$text bold="true">d</$text></paragraph>' );
-		} );
-
-		it( 'pastes inside another italic element', () => {
-			setData( editor.model, '<paragraph><$text italic="true">Italic[]</$text></paragraph>' );
+	// Pastes:
+	//		<p><i>Italic</i> text.</p>
+	it( 'pastes italic starting text', () => {
+		const expected = '<paragraph><$text italic="true">Italic</$text> text.</paragraph>';
 
-			expectPaste( editor, fixtures.italicStartingText, '<paragraph><$text italic="true">ItalicItalic</$text> text.[]</paragraph>' );
-		} );
+		expectModel( editor, input.italicStartingText, expected );
 	} );
 
-	// Pastes: '<u>Whole text underlined</u>'
-	// Input same for: Chrome, Firefox and Edge.
-	describe( 'underlined text', () => {
-		it( 'pastes in the empty editor', () => {
-			expectPaste( editor, fixtures.underlinedText,
-				'<paragraph><$text underline="true">Whole text underlined[]</$text></paragraph>' );
-		} );
-
-		it( 'pastes in the paragraph', () => {
-			setData( editor.model, '<paragraph>More [] text</paragraph>' );
-
-			expectPaste( editor, fixtures.underlinedText, '<paragraph>More <$text underline="true">Whole text underlined[]' +
-				'</$text> text</paragraph>' );
-		} );
-
-		it( 'pastes in the different block context', () => {
-			setData( editor.model, '<heading1>More [] text</heading1>' );
-
-			expectPaste( editor, fixtures.underlinedText,
-				'<heading1>More <$text underline="true">Whole text underlined[]</$text> text</heading1>' );
-		} );
-
-		it( 'pastes in the inline styling context', () => {
-			setData( editor.model, '<paragraph><$text bold="true">Bol[]d</$text></paragraph>' );
-
-			expectPaste( editor, fixtures.underlinedText, '<paragraph><$text bold="true">Bol</$text><$text underline="true">' +
-				'Whole text underlined[]</$text><$text bold="true">d</$text></paragraph>' );
-		} );
-
-		it( 'pastes inside another underlined element', () => {
-			setData( editor.model, '<paragraph><$text underline="true">Under []line</$text></paragraph>' );
+	// Pastes:
+	//		<p><u>Whole text underlined</u></p>
+	it( 'pastes underlined text', () => {
+		const expected = '<paragraph><$text underline="true">Whole text underlined</$text></paragraph>';
 
-			expectPaste( editor, fixtures.underlinedText, '<paragraph><$text underline="true">Under Whole text underlined[]' +
-				'line</$text></paragraph>' );
-		} );
+		expectModel( editor, input.underlinedText, expected );
 	} );
 
-	// Pastes: 'Text <s>incorrect</s>'
-	// Input same for: Chrome, Firefox and Edge.
-	describe( 'strikethrough ending text', () => {
-		it( 'pastes in the empty editor', () => {
-			expectPaste( editor, fixtures.strikethroughEndingText,
-				'<paragraph>Text <$text strikethrough="true">incorrect[]</$text></paragraph>' );
-		} );
-
-		it( 'pastes in the paragraph', () => {
-			setData( editor.model, '<paragraph>More [] text</paragraph>' );
-
-			expectPaste( editor, fixtures.strikethroughEndingText, '<paragraph>More Text <$text strikethrough="true">incorrect[]' +
-				'</$text> text</paragraph>' );
-		} );
-
-		it( 'pastes in the different block context', () => {
-			setData( editor.model, '<heading1>More [] text</heading1>' );
-
-			expectPaste( editor, fixtures.strikethroughEndingText, '<heading1>More Text <$text strikethrough="true">incorrect[]' +
-				'</$text> text</heading1>' );
-		} );
-
-		it( 'pastes in the inline styling context', () => {
-			setData( editor.model, '<paragraph><$text bold="true">Bol[]d</$text></paragraph>' );
-
-			expectPaste( editor, fixtures.strikethroughEndingText, '<paragraph><$text bold="true">Bol</$text>' +
-				'Text <$text strikethrough="true">incorrect[]</$text><$text bold="true">d</$text></paragraph>' );
-		} );
-
-		it( 'pastes inside another strikethrough element', () => {
-			setData( editor.model, '<paragraph><$text strikethrough="true">[]Foo</$text></paragraph>' );
+	// Pastes:
+	//		<p>Text <s>incorrect</s></p>
+	it( 'pastes strikethrough ending text', () => {
+		const expected = '<paragraph>Text <$text strikethrough="true">incorrect</$text></paragraph>';
 
-			expectPaste( editor, fixtures.strikethroughEndingText, '<paragraph>Text <$text strikethrough="true">incorrect[]Foo' +
-				'</$text></paragraph>' );
-		} );
+		expectModel( editor, input.strikethroughEndingText, expected );
 	} );
 
-	// Pastes: 'Text <b><u>containi<s>ng</s></u></b><s><u> multi</u>ple</s><i>styling</i>.'
-	// Input same for: Chrome, Firefox and Edge.
-	describe( 'mulitple styles single line', () => {
-		it( 'pastes in the empty editor', () => {
-			expectPaste( editor, fixtures.multipleStylesSingleLine, '<paragraph>Text ' +
-				'<$text bold="true" underline="true">containi</$text>' +
-				'<$text bold="true" strikethrough="true" underline="true">ng</$text>' +
-				'<$text strikethrough="true" underline="true"> multi</$text>' +
-				'<$text strikethrough="true">ple </$text>' +
-				'<$text italic="true">styling</$text>.[]</paragraph>' );
-		} );
-
-		it( 'pastes in the paragraph', () => {
-			setData( editor.model, '<paragraph>More [] text</paragraph>' );
-
-			expectPaste( editor, fixtures.multipleStylesSingleLine, '<paragraph>More Text ' +
-				'<$text bold="true" underline="true">containi</$text>' +
-				'<$text bold="true" strikethrough="true" underline="true">ng</$text>' +
-				'<$text strikethrough="true" underline="true"> multi</$text>' +
-				'<$text strikethrough="true">ple </$text>' +
-				'<$text italic="true">styling</$text>.[] text</paragraph>' );
-		} );
-
-		it( 'pastes in the different block context', () => {
-			setData( editor.model, '<heading1>More [] text</heading1>' );
-
-			expectPaste( editor, fixtures.multipleStylesSingleLine, '<heading1>More Text ' +
-				'<$text bold="true" underline="true">containi</$text>' +
-				'<$text bold="true" strikethrough="true" underline="true">ng</$text>' +
-				'<$text strikethrough="true" underline="true"> multi</$text>' +
-				'<$text strikethrough="true">ple </$text>' +
-				'<$text italic="true">styling</$text>.[] text</heading1>' );
-		} );
-
-		it( 'pastes in the inline styling context', () => {
-			setData( editor.model, '<paragraph><$text bold="true">Bol[]d</$text></paragraph>' );
-
-			expectPaste( editor, fixtures.multipleStylesSingleLine, '<paragraph><$text bold="true">Bol</$text>Text ' +
-				'<$text bold="true" underline="true">containi</$text>' +
-				'<$text bold="true" strikethrough="true" underline="true">ng</$text>' +
-				'<$text strikethrough="true" underline="true"> multi</$text>' +
-				'<$text strikethrough="true">ple </$text>' +
-				'<$text italic="true">styling</$text>.[]' +
-				'<$text bold="true">d</$text></paragraph>' );
-		} );
+	// Pastes:
+	//		<p>Text <b><u>containi<s>ng</s></u></b><s><u> multi</u>ple</s><i>styling</i>.</p>
+	it( 'pastes mulitple styles single line', () => {
+		const expected = '<paragraph>Text ' +
+			'<$text bold="true" underline="true">containi</$text>' +
+			'<$text bold="true" strikethrough="true" underline="true">ng</$text>' +
+			'<$text strikethrough="true" underline="true"> multi</$text>' +
+			'<$text strikethrough="true">ple </$text>' +
+			'<$text italic="true">styling</$text>.</paragraph>';
+
+		expectModel( editor, input.multipleStylesSingleLine, expected );
 	} );
 
 	// Pastes:
 	//		<p>Line <b>bold</b> and <i>italics</i></p>
 	//		<p>Line <b><u>foo</u></b><u> bar</u></p>
 	//		<p><s>Third</s> line <b>styling, <i>space on e</i>nd </b></p>
-	// Input same for: Chrome, Firefox and Edge.
-	describe( 'mulitple styles multiline', () => {
-		it( 'pastes in the empty editor', () => {
-			expectPaste( editor, fixtures.multipleStylesMultiline, '<paragraph>Line ' +
-				'<$text bold="true">bold</$text> and <$text italic="true">italics</$text></paragraph>' +
-				'<paragraph>Line <$text bold="true" underline="true">foo</$text><$text underline="true"> bar</$text></paragraph>' +
-				'<paragraph><$text strikethrough="true">Third</$text> line <$text bold="true">styling, </$text>' +
-				'<$text bold="true" italic="true">space on e</$text>' +
-				'<$text bold="true">nd []</$text></paragraph>' ); // The last space '...nd </b></p>' goes missing.
-		} );
-
-		it( 'pastes in the paragraph', () => {
-			setData( editor.model, '<paragraph>More [] text</paragraph>' );
-
-			expectPaste( editor, fixtures.multipleStylesMultiline, '<paragraph>More Line ' +
-				'<$text bold="true">bold</$text> and <$text italic="true">italics</$text></paragraph>' +
-				'<paragraph>Line <$text bold="true" underline="true">foo</$text><$text underline="true"> bar</$text></paragraph>' +
-				'<paragraph><$text strikethrough="true">Third</$text> line <$text bold="true">styling, </$text>' +
-				'<$text bold="true" italic="true">space on e</$text>' +
-				'<$text bold="true">nd []</$text> text</paragraph>' ); // The last space '...nd </b></p>' goes missing.
-		} );
-
-		it( 'pastes in the different block context', () => {
-			setData( editor.model, '<heading1>More [] text</heading1>' );
-
-			expectPaste( editor, fixtures.multipleStylesMultiline, '<heading1>More Line ' +
-				'<$text bold="true">bold</$text> and <$text italic="true">italics</$text></heading1>' +
-				'<paragraph>Line <$text bold="true" underline="true">foo</$text><$text underline="true"> bar</$text></paragraph>' +
-				'<paragraph><$text strikethrough="true">Third</$text> line <$text bold="true">styling, </$text>' +
-				'<$text bold="true" italic="true">space on e</$text>' +
-				'<$text bold="true">nd []</$text> text</paragraph>' ); // The last space '...nd </b></p>' goes missing.
-		} );
-
-		it( 'pastes in the inline styling context', () => {
-			setData( editor.model, '<paragraph><$text bold="true">Bol[]d</$text></paragraph>' );
-
-			expectPaste( editor, fixtures.multipleStylesMultiline, '<paragraph><$text bold="true">Bol</$text>Line ' +
-				'<$text bold="true">bold</$text> and <$text italic="true">italics</$text></paragraph>' +
-				'<paragraph>Line <$text bold="true" underline="true">foo</$text><$text underline="true"> bar</$text></paragraph>' +
-				'<paragraph><$text strikethrough="true">Third</$text> line <$text bold="true">styling, </$text>' +
-				'<$text bold="true" italic="true">space on e</$text>' +
-				'<$text bold="true">nd []d</$text></paragraph>' ); // The last space '...nd </b></p>' goes missing.
-		} );
+	it( 'pastes mulitple styles multiline', () => {
+		const expected = '<paragraph>Line ' +
+			'<$text bold="true">bold</$text> and <$text italic="true">italics</$text></paragraph>' +
+			'<paragraph>Line <$text bold="true" underline="true">foo</$text><$text underline="true"> bar</$text></paragraph>' +
+			'<paragraph><$text strikethrough="true">Third</$text> line <$text bold="true">styling, </$text>' +
+			'<$text bold="true" italic="true">space on e</$text>' +
+			'<$text bold="true">nd </$text></paragraph>';
+
+		expectModel( editor, input.multipleStylesMultiline, expected );
 	} );
 } );

+ 12 - 21
packages/ckeditor5-paste-from-office/tests/data/normalization/basic-styles.js

@@ -8,23 +8,14 @@ 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';
+import { getFixtures } from '../../_utils/fixtures';
 
 describe( 'Basic Styles – normalization', () => {
-	let editor, pasteFromOfficePlugin;
+	let editor, input, normalized, pasteFromOfficePlugin;
+
+	before( () => {
+		( { input, normalized } = getFixtures( 'basic-styles' ) );
+	} );
 
 	beforeEach( () => {
 		return VirtualTestEditor
@@ -40,31 +31,31 @@ describe( 'Basic Styles – normalization', () => {
 
 	it( 'normalizes bold within text', () => {
 		expectNormalized(
-			pasteFromOfficePlugin._normalizeWordInput( boldWithinText, editor ), boldWithinTextNormalized );
+			pasteFromOfficePlugin._normalizeWordInput( input.boldWithinText, editor ), normalized.boldWithinText );
 	} );
 
 	it( 'normalizes italic starting text', () => {
 		expectNormalized(
-			pasteFromOfficePlugin._normalizeWordInput( italicStartingText, editor ), italicStartingTextNormalized );
+			pasteFromOfficePlugin._normalizeWordInput( input.italicStartingText, editor ), normalized.italicStartingText );
 	} );
 
 	it( 'normalizes underlined text', () => {
 		expectNormalized(
-			pasteFromOfficePlugin._normalizeWordInput( underlinedText, editor ), underlinedTextNormalized );
+			pasteFromOfficePlugin._normalizeWordInput( input.underlinedText, editor ), normalized.underlinedText );
 	} );
 
 	it( 'normalizes strikethrough ending text', () => {
 		expectNormalized(
-			pasteFromOfficePlugin._normalizeWordInput( strikethroughEndingText, editor ), strikethroughEndingTextNormalized );
+			pasteFromOfficePlugin._normalizeWordInput( input.strikethroughEndingText, editor ), normalized.strikethroughEndingText );
 	} );
 
 	it( 'normalizes mulitple styles single line', () => {
 		expectNormalized(
-			pasteFromOfficePlugin._normalizeWordInput( multipleStylesSingleLine, editor ), multipleStylesSingleLineNormalized );
+			pasteFromOfficePlugin._normalizeWordInput( input.multipleStylesSingleLine, editor ), normalized.multipleStylesSingleLine );
 	} );
 
 	it( 'normalizes mulitple styles multiline', () => {
 		expectNormalized(
-			pasteFromOfficePlugin._normalizeWordInput( multipleStylesMultiline, editor ), multipleStylesMultilineNormalized );
+			pasteFromOfficePlugin._normalizeWordInput( input.multipleStylesMultiline, editor ), normalized.multipleStylesMultiline );
 	} );
 } );