tablecellpropertiesui.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* globals document */
  6. import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
  7. import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
  8. // import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
  9. // import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  10. // import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
  11. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  12. import ContextualBalloon from '@ckeditor/ckeditor5-ui/src/panel/balloon/contextualballoon';
  13. import Table from '@ckeditor/ckeditor5-table/src/table';
  14. import TableCellPropertiesUI from '@ckeditor/ckeditor5-table/src/tablecellpropertiesui';
  15. import TableCellPropertiesUIView from '@ckeditor/ckeditor5-table/src/ui/tablecellpropertiesview';
  16. import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
  17. // import View from '@ckeditor/ckeditor5-ui/src/view';
  18. describe.only( 'TableCellPropertiesUI', () => {
  19. let editor, editorElement, contextualBalloon,
  20. tableCellPropertiesUI, tableCellPropertiesButton;
  21. testUtils.createSinonSandbox();
  22. beforeEach( () => {
  23. editorElement = document.createElement( 'div' );
  24. document.body.appendChild( editorElement );
  25. return ClassicTestEditor
  26. .create( editorElement, {
  27. plugins: [ Table, TableCellPropertiesUI, Paragraph ]
  28. } )
  29. .then( newEditor => {
  30. editor = newEditor;
  31. tableCellPropertiesUI = editor.plugins.get( TableCellPropertiesUI );
  32. tableCellPropertiesButton = editor.ui.componentFactory.create( 'tableCellProperties' );
  33. contextualBalloon = editor.plugins.get( ContextualBalloon );
  34. // tableCellPropertiesView = tableCellPropertiesUI.view;
  35. // There is no point to execute BalloonPanelView attachTo and pin methods so lets override it.
  36. testUtils.sinon.stub( contextualBalloon.view, 'attachTo' ).returns( {} );
  37. testUtils.sinon.stub( contextualBalloon.view, 'pin' ).returns( {} );
  38. } );
  39. } );
  40. afterEach( () => {
  41. editorElement.remove();
  42. return editor.destroy();
  43. } );
  44. it( 'should be named', () => {
  45. expect( TableCellPropertiesUI.pluginName ).to.equal( 'TableCellPropertiesUI' );
  46. } );
  47. it( 'should load ContextualBalloon', () => {
  48. expect( editor.plugins.get( ContextualBalloon ) ).to.be.instanceOf( ContextualBalloon );
  49. } );
  50. describe( 'init()', () => {
  51. it( 'should set a batch', () => {
  52. expect( tableCellPropertiesUI._batch ).to.be.null;
  53. } );
  54. describe( '#view', () => {
  55. it( 'should be created', () => {
  56. expect( tableCellPropertiesUI.view ).to.be.instanceOf( TableCellPropertiesUIView );
  57. } );
  58. it( 'should be rendered', () => {
  59. expect( tableCellPropertiesUI.view.isRendered ).to.be.true;
  60. } );
  61. } );
  62. describe( 'toolbar button', () => {
  63. it( 'should be registered', () => {
  64. expect( tableCellPropertiesButton ).to.be.instanceOf( ButtonView );
  65. } );
  66. it( 'should have a label', () => {
  67. expect( tableCellPropertiesButton.label ).to.equal( 'Cell properties' );
  68. } );
  69. it( 'should have a tooltip', () => {
  70. expect( tableCellPropertiesButton.tooltip ).to.be.true;
  71. } );
  72. it( 'should call #_showView upon #execute', () => {
  73. const spy = testUtils.sinon.stub( tableCellPropertiesUI, '_showView' ).returns( {} );
  74. tableCellPropertiesButton.fire( 'execute' );
  75. sinon.assert.calledOnce( spy );
  76. } );
  77. } );
  78. } );
  79. } );