integration.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* global document */
  6. import Font from '../src/font';
  7. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  8. import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
  9. import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  10. import env from '@ckeditor/ckeditor5-utils/src/env';
  11. describe( 'Integration test Font', () => {
  12. let element, editor, model;
  13. beforeEach( () => {
  14. element = document.createElement( 'div' );
  15. document.body.appendChild( element );
  16. return ClassicTestEditor
  17. .create( element, {
  18. plugins: [ Font, ArticlePluginSet ]
  19. } )
  20. .then( newEditor => {
  21. editor = newEditor;
  22. model = editor.model;
  23. } );
  24. } );
  25. afterEach( () => {
  26. element.remove();
  27. return editor.destroy();
  28. } );
  29. describe( 'in-between font plugin features', () => {
  30. it( 'should render one span element for all types of font features', () => {
  31. setModelData( model,
  32. '<paragraph>' +
  33. '<$text fontColor="#123456" fontBackgroundColor="rgb(10,20,30)" fontSize="big" fontFamily="Arial">foo</$text>' +
  34. '</paragraph>'
  35. );
  36. if ( !env.isEdge ) {
  37. expect( editor.getData() ).to.equal(
  38. '<p>' +
  39. '<span ' +
  40. 'class="text-big" ' +
  41. 'style="font-family:Arial, Helvetica, sans-serif;background-color:rgb(10,20,30);color:#123456;"' +
  42. '>foo' +
  43. '</span>' +
  44. '</p>'
  45. );
  46. } else {
  47. // Edge sorts attributes of an element.
  48. expect( editor.getData() ).to.equal(
  49. '<p>' +
  50. '<span ' +
  51. 'class="text-big" ' +
  52. 'style="font-family:Arial, Helvetica, sans-serif;color:#123456;background-color:rgb(10,20,30);"' +
  53. '>foo' +
  54. '</span>' +
  55. '</p>'
  56. );
  57. }
  58. } );
  59. } );
  60. describe( 'between font plugin and other', () => {
  61. it( 'should render elements wrapped in proper order', () => {
  62. setModelData( model,
  63. '<paragraph>' +
  64. '<$text bold="true" linkHref="foo" fontColor="red" fontSize="big">foo</$text>' +
  65. '</paragraph>'
  66. );
  67. expect( editor.getData() ).to.equal(
  68. '<p>' +
  69. '<a href="foo">' +
  70. '<span class="text-big" style="color:red;">' +
  71. '<strong>foo</strong>' +
  72. '</span>' +
  73. '</a>' +
  74. '</p>'
  75. );
  76. } );
  77. } );
  78. } );