tablecolumnrowproperties.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  6. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  7. import TableEditing from '../src/tableediting';
  8. import TableColumnRowProperties from '../src/tablecolumnrowproperites';
  9. import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  10. import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
  11. describe( 'TableColumnRowProperties', () => {
  12. let editor, model;
  13. beforeEach( () => {
  14. return VirtualTestEditor
  15. .create( {
  16. plugins: [ TableColumnRowProperties, Paragraph, TableEditing ]
  17. } )
  18. .then( newEditor => {
  19. editor = newEditor;
  20. model = editor.model;
  21. } );
  22. } );
  23. afterEach( () => {
  24. editor.destroy();
  25. } );
  26. it( 'should have pluginName', () => {
  27. expect( TableColumnRowProperties.pluginName ).to.equal( 'TableColumnRowProperties' );
  28. } );
  29. it( 'should set proper schema rules', () => {
  30. // expect( model.schema.checkAttribute( [ '$root', 'tableCell' ], 'width' ) ).to.be.true;
  31. // expect( model.schema.checkAttribute( [ '$root', 'tableCell' ], 'height' ) ).to.be.true;
  32. } );
  33. describe( 'conversion', () => {
  34. describe( 'upcast', () => {
  35. it( 'should upcast height attribute', () => {
  36. editor.setData( '<table><tr style="height:20px"><td>foo</td></tr></table>' );
  37. const tableRow = model.document.getRoot().getNodeByPath( [ 0, 0 ] );
  38. expect( tableRow.getAttribute( 'height' ) ).to.equal( '20px' );
  39. } );
  40. } );
  41. describe( 'downcast', () => {
  42. let tableRow;
  43. beforeEach( () => {
  44. setModelData(
  45. model,
  46. '<table headingRows="0" headingColumns="0">' +
  47. '<tableRow>' +
  48. '<tableCell>' +
  49. '<paragraph>foo</paragraph>' +
  50. '</tableCell>' +
  51. '</tableRow>' +
  52. '</table>'
  53. );
  54. tableRow = model.document.getRoot().getNodeByPath( [ 0, 0 ] );
  55. } );
  56. it( 'should downcast height attribute', () => {
  57. model.change( writer => writer.setAttribute( 'height', '20px', tableRow ) );
  58. assertEqualMarkup(
  59. editor.getData(),
  60. '<figure class="table"><table><tbody><tr style="height:20px;"><td>foo</td></tr></tbody></table></figure>'
  61. );
  62. } );
  63. } );
  64. } );
  65. } );