tablecolumnrowproperties.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  6. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  7. import Widget from '@ckeditor/ckeditor5-widget/src/widget';
  8. import TableEditing from '../../src/tableediting';
  9. import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  10. import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
  11. import TableColumnRowProperties from '../../src/tablecolumnrowproperites';
  12. describe( 'Table styles conversion', () => {
  13. let editor, model;
  14. beforeEach( () => {
  15. return VirtualTestEditor
  16. .create( {
  17. plugins: [ TableEditing, TableColumnRowProperties, Paragraph, Widget ]
  18. } )
  19. .then( newEditor => {
  20. editor = newEditor;
  21. model = editor.model;
  22. // Since this part of test tests only data conversion so editing pipeline is not necessary.
  23. editor.editing.destroy();
  24. } );
  25. } );
  26. describe( 'upcast', () => {
  27. it( 'should upcast height attribute', () => {
  28. editor.setData( '<table><tr style="height:20px"><td>foo</td></tr></table>' );
  29. const tableRow = model.document.getRoot().getNodeByPath( [ 0, 0 ] );
  30. expect( tableRow.getAttribute( 'height' ) ).to.equal( '20px' );
  31. } );
  32. } );
  33. describe( 'downcast', () => {
  34. let tableRow;
  35. beforeEach( () => {
  36. setModelData(
  37. model,
  38. '<table headingRows="0" headingColumns="0">' +
  39. '<tableRow>' +
  40. '<tableCell>' +
  41. '<paragraph>foo</paragraph>' +
  42. '</tableCell>' +
  43. '</tableRow>' +
  44. '</table>'
  45. );
  46. tableRow = model.document.getRoot().getNodeByPath( [ 0, 0 ] );
  47. } );
  48. it( 'should downcast height attribute', () => {
  49. model.change( writer => writer.setAttribute( 'height', '20px', tableRow ) );
  50. assertEqualMarkup(
  51. editor.getData(),
  52. '<figure class="table"><table><tbody><tr style="height:20px;"><td>foo</td></tr></tbody></table></figure>'
  53. );
  54. } );
  55. } );
  56. } );