list.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  6. import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
  7. import PasteFromOffice from '../../../src/pastefromoffice';
  8. import { expectNormalized } from '../../_utils/utils';
  9. import simple from '../../_data/list/simple/input.word2016.html';
  10. import styled from '../../_data/list/styled/input.word2016.html';
  11. import multiple from '../../_data/list/multiple/input.word2016.html';
  12. import multipleCombined from '../../_data/list/multiple-combined/input.word2016.html';
  13. import manyOneItem from '../../_data/list/many-one-item/input.word2016.html';
  14. import heading1 from '../../_data/list/heading1/input.word2016.html';
  15. import heading3Styled from '../../_data/list/heading3-styled/input.word2016.html';
  16. import heading7 from '../../_data/list/heading7/input.word2016.html';
  17. import simpleNormalized from '../../_data/list/simple/normalized.word2016.html';
  18. import styledNormalized from '../../_data/list/styled/normalized.word2016.html';
  19. import multipleNormalized from '../../_data/list/multiple/normalized.word2016.html';
  20. import multipleCombinedNormalized from '../../_data/list/multiple-combined/normalized.word2016.html';
  21. import manyOneItemNormalized from '../../_data/list/many-one-item/normalized.word2016.html';
  22. import heading1Normalized from '../../_data/list/heading1/normalized.word2016.html';
  23. import heading3StyledNormalized from '../../_data/list/heading3-styled/normalized.word2016.html';
  24. import heading7Normalized from '../../_data/list/heading7/normalized.word2016.html';
  25. describe( 'List – normalization', () => {
  26. let editor, pasteFromOfficePlugin;
  27. beforeEach( () => {
  28. return VirtualTestEditor
  29. .create( {
  30. plugins: [ Clipboard, PasteFromOffice ]
  31. } )
  32. .then( newEditor => {
  33. editor = newEditor;
  34. pasteFromOfficePlugin = editor.plugins.get( 'PasteFromOffice' );
  35. } );
  36. } );
  37. it( 'normalizes simple list', () => {
  38. expectNormalized( pasteFromOfficePlugin._normalizeWordInput( simple, editor ), simpleNormalized );
  39. } );
  40. it( 'normalizes list with styled items prepended by a paragraph', () => {
  41. expectNormalized( pasteFromOfficePlugin._normalizeWordInput( styled, editor ), styledNormalized );
  42. } );
  43. it( 'normalizes multiple lists separated by the paragraph', () => {
  44. expectNormalized( pasteFromOfficePlugin._normalizeWordInput( multiple, editor ), multipleNormalized );
  45. } );
  46. it( 'normalizes multiple lists one right after another', () => {
  47. expectNormalized( pasteFromOfficePlugin._normalizeWordInput( multipleCombined, editor ), multipleCombinedNormalized );
  48. } );
  49. it( 'normalizes many one item lists', () => {
  50. expectNormalized( pasteFromOfficePlugin._normalizeWordInput( manyOneItem, editor ), manyOneItemNormalized );
  51. } );
  52. it( 'normalizes list created from headings (h1)', () => {
  53. expectNormalized( pasteFromOfficePlugin._normalizeWordInput( heading1, editor ), heading1Normalized );
  54. } );
  55. it( 'normalizes list created from styled headings (h3)', () => {
  56. expectNormalized( pasteFromOfficePlugin._normalizeWordInput( heading3Styled, editor ), heading3StyledNormalized );
  57. } );
  58. it( 'normalizes list created from heading (h7)', () => {
  59. expectNormalized( pasteFromOfficePlugin._normalizeWordInput( heading7, editor ), heading7Normalized );
  60. } );
  61. } );