| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693 |
- /**
- * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- /* global document, window, Event */
- import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
- import BlockToolbar from '../../../src/toolbar/block/blocktoolbar';
- import ToolbarView from '../../../src/toolbar/toolbarview';
- import BalloonPanelView from '../../../src/panel/balloon/balloonpanelview';
- import BlockButtonView from '../../../src/toolbar/block/blockbuttonview';
- import Heading from '@ckeditor/ckeditor5-heading/src/heading';
- import HeadingButtonsUI from '@ckeditor/ckeditor5-heading/src/headingbuttonsui';
- import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
- import ParagraphButtonUI from '@ckeditor/ckeditor5-paragraph/src/paragraphbuttonui';
- import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote';
- import Image from '@ckeditor/ckeditor5-image/src/image';
- import ImageCaption from '@ckeditor/ckeditor5-image/src/imagecaption';
- import global from '@ckeditor/ckeditor5-utils/src/dom/global';
- import ResizeObserver from '@ckeditor/ckeditor5-utils/src/dom/resizeobserver';
- import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
- import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
- import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
- import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
- describe( 'BlockToolbar', () => {
- let editor, element, blockToolbar;
- let resizeCallback;
- testUtils.createSinonSandbox();
- beforeEach( () => {
- element = document.createElement( 'div' );
- document.body.appendChild( element );
- // Make sure other tests of the editor do not affect tests that follow.
- // Without it, if an instance of ResizeObserver already exists somewhere undestroyed
- // in DOM, the following DOM mock will have no effect.
- ResizeObserver._observerInstance = null;
- testUtils.sinon.stub( global.window, 'ResizeObserver' ).callsFake( callback => {
- resizeCallback = callback;
- return {
- observe: sinon.spy(),
- unobserve: sinon.spy()
- };
- } );
- return ClassicTestEditor.create( element, {
- plugins: [ BlockToolbar, Heading, HeadingButtonsUI, Paragraph, ParagraphButtonUI, BlockQuote, Image, ImageCaption ],
- blockToolbar: [ 'paragraph', 'heading1', 'heading2', 'blockQuote' ]
- } ).then( newEditor => {
- editor = newEditor;
- blockToolbar = editor.plugins.get( BlockToolbar );
- editor.ui.focusTracker.isFocused = true;
- } );
- } );
- afterEach( () => {
- // Blur editor so `blockToolbar.buttonView` `window.resize` listener is detached.
- editor.ui.focusTracker.isFocused = false;
- element.remove();
- return editor.destroy();
- } );
- it( 'should have pluginName property', () => {
- expect( BlockToolbar.pluginName ).to.equal( 'BlockToolbar' );
- } );
- it( 'should not throw when empty config is provided', async () => {
- // Remove default editor instance.
- await editor.destroy();
- editor = await ClassicTestEditor.create( element, {
- plugins: [ BlockToolbar ]
- } );
- } );
- it( 'should accept the extended format of the toolbar config', () => {
- return ClassicTestEditor
- .create( element, {
- plugins: [ BlockToolbar, Heading, HeadingButtonsUI, Paragraph, ParagraphButtonUI, BlockQuote ],
- blockToolbar: {
- items: [ 'paragraph', 'heading1', 'heading2', 'blockQuote' ]
- }
- } )
- .then( editor => {
- blockToolbar = editor.plugins.get( BlockToolbar );
- expect( blockToolbar.toolbarView.items ).to.length( 4 );
- element.remove();
- return editor.destroy();
- } );
- } );
- it( 'should not group items when the config.shouldNotGroupWhenFull option is enabled', () => {
- return ClassicTestEditor.create( element, {
- plugins: [ BlockToolbar, Heading, HeadingButtonsUI, Paragraph, ParagraphButtonUI, BlockQuote ],
- blockToolbar: {
- items: [ 'paragraph', 'heading1', 'heading2', 'blockQuote' ],
- shouldNotGroupWhenFull: true
- }
- } ).then( editor => {
- const blockToolbar = editor.plugins.get( BlockToolbar );
- expect( blockToolbar.toolbarView.options.shouldGroupWhenFull ).to.be.false;
- element.remove();
- return editor.destroy();
- } );
- } );
- describe( 'child views', () => {
- describe( 'panelView', () => {
- it( 'should create a view instance', () => {
- expect( blockToolbar.panelView ).to.instanceof( BalloonPanelView );
- } );
- it( 'should have an additional class name', () => {
- expect( blockToolbar.panelView.class ).to.equal( 'ck-toolbar-container' );
- } );
- it( 'should be added to the ui.view.body collection', () => {
- expect( Array.from( editor.ui.view.body ) ).to.include( blockToolbar.panelView );
- } );
- it( 'should add the #panelView to ui.focusTracker', () => {
- editor.ui.focusTracker.isFocused = false;
- blockToolbar.panelView.element.dispatchEvent( new Event( 'focus' ) );
- expect( editor.ui.focusTracker.isFocused ).to.be.true;
- } );
- it( 'should close the #panelView after `Esc` is pressed and focus view document', () => {
- const spy = testUtils.sinon.spy( editor.editing.view, 'focus' );
- blockToolbar.panelView.isVisible = true;
- blockToolbar.toolbarView.keystrokes.press( {
- keyCode: keyCodes.esc,
- preventDefault: () => {},
- stopPropagation: () => {}
- } );
- expect( blockToolbar.panelView.isVisible ).to.be.false;
- sinon.assert.calledOnce( spy );
- } );
- it( 'should close the #panelView upon click outside the panel and not focus view document', () => {
- const spy = testUtils.sinon.spy();
- editor.editing.view.on( 'focus', spy );
- blockToolbar.panelView.isVisible = true;
- document.body.dispatchEvent( new Event( 'mousedown', { bubbles: true } ) );
- expect( blockToolbar.panelView.isVisible ).to.be.false;
- sinon.assert.notCalled( spy );
- } );
- it( 'should not close the #panelView upon click on panel element', () => {
- blockToolbar.panelView.isVisible = true;
- blockToolbar.panelView.element.dispatchEvent( new Event( 'mousedown', { bubbles: true } ) );
- expect( blockToolbar.panelView.isVisible ).to.be.true;
- } );
- } );
- describe( 'toolbarView', () => {
- it( 'should create the view instance', () => {
- expect( blockToolbar.toolbarView ).to.instanceof( ToolbarView );
- } );
- it( 'should add an additional class to toolbar element', () => {
- expect( blockToolbar.toolbarView.element.classList.contains( 'ck-toolbar_floating' ) ).to.be.true;
- } );
- it( 'should be added to the panelView#content collection', () => {
- expect( Array.from( blockToolbar.panelView.content ) ).to.include( blockToolbar.toolbarView );
- } );
- it( 'should initialize the toolbar items based on Editor#blockToolbar config', () => {
- expect( Array.from( blockToolbar.toolbarView.items ) ).to.length( 4 );
- } );
- it( 'should hide the panel after clicking on the button from toolbar', () => {
- blockToolbar.buttonView.fire( 'execute' );
- expect( blockToolbar.panelView.isVisible ).to.be.true;
- blockToolbar.toolbarView.items.get( 0 ).fire( 'execute' );
- expect( blockToolbar.panelView.isVisible ).to.be.false;
- } );
- it( 'should hide the panel on toolbar blur', () => {
- blockToolbar.toolbarView.focusTracker.isFocused = true;
- blockToolbar.buttonView.fire( 'execute' );
- expect( blockToolbar.panelView.isVisible ).to.be.true;
- blockToolbar.toolbarView.focusTracker.isFocused = false;
- expect( blockToolbar.panelView.isVisible ).to.be.false;
- } );
- } );
- describe( 'buttonView', () => {
- it( 'should create a view instance', () => {
- expect( blockToolbar.buttonView ).to.instanceof( BlockButtonView );
- } );
- it( 'should be added to the editor ui.view.body collection', () => {
- expect( Array.from( editor.ui.view.body ) ).to.include( blockToolbar.buttonView );
- } );
- it( 'should add the #buttonView to the ui.focusTracker', () => {
- editor.ui.focusTracker.isFocused = false;
- blockToolbar.buttonView.element.dispatchEvent( new Event( 'focus' ) );
- expect( editor.ui.focusTracker.isFocused ).to.be.true;
- } );
- it( 'should pin the #panelView to the button and focus first item in toolbar on #execute event', () => {
- expect( blockToolbar.panelView.isVisible ).to.be.false;
- const pinSpy = testUtils.sinon.spy( blockToolbar.panelView, 'pin' );
- const focusSpy = testUtils.sinon.spy( blockToolbar.toolbarView.items.get( 0 ), 'focus' );
- blockToolbar.buttonView.fire( 'execute' );
- expect( blockToolbar.panelView.isVisible ).to.be.true;
- sinon.assert.calledWith( pinSpy, {
- target: blockToolbar.buttonView.element,
- limiter: editor.ui.getEditableElement()
- } );
- sinon.assert.calledOnce( focusSpy );
- } );
- it( 'should hide the #panelView and focus the editable on #execute event when panel was visible', () => {
- blockToolbar.panelView.isVisible = true;
- const spy = testUtils.sinon.spy( editor.editing.view, 'focus' );
- blockToolbar.buttonView.fire( 'execute' );
- expect( blockToolbar.panelView.isVisible ).to.be.false;
- sinon.assert.calledOnce( spy );
- } );
- it( 'should bind #isOn to panelView#isVisible', () => {
- blockToolbar.panelView.isVisible = false;
- expect( blockToolbar.buttonView.isOn ).to.be.false;
- blockToolbar.panelView.isVisible = true;
- expect( blockToolbar.buttonView.isOn ).to.be.true;
- } );
- it( 'should hide the #button tooltip when the #panelView is open', () => {
- blockToolbar.panelView.isVisible = false;
- expect( blockToolbar.buttonView.tooltip ).to.be.true;
- blockToolbar.panelView.isVisible = true;
- expect( blockToolbar.buttonView.tooltip ).to.be.false;
- } );
- it( 'should hide the #button if empty config was passed', async () => {
- // Remove default editor instance.
- await editor.destroy();
- editor = await ClassicTestEditor.create( element, {
- plugins: [ BlockToolbar ]
- } );
- const blockToolbar = editor.plugins.get( BlockToolbar );
- expect( blockToolbar.buttonView.isVisible ).to.be.false;
- } );
- } );
- } );
- describe( 'allowed elements', () => {
- it( 'should display the button when the first selected block is a block element', () => {
- editor.model.schema.register( 'foo', { inheritAllFrom: '$block' } );
- editor.conversion.elementToElement( { model: 'foo', view: 'foo' } );
- setData( editor.model, '<foo>foo[]bar</foo>' );
- expect( blockToolbar.buttonView.isVisible ).to.be.true;
- } );
- it( 'should display the button when the first selected block is an object', () => {
- setData( editor.model, '[<image src="/assets/sample.png"><caption>foo</caption></image>]' );
- expect( blockToolbar.buttonView.isVisible ).to.be.true;
- } );
- // This test makes no sense now, but so do all other tests here (see https://github.com/ckeditor/ckeditor5/issues/1522).
- it( 'should not display the button when the selection is inside a limit element', () => {
- setData( editor.model, '<image src="/assets/sample.png"><caption>f[]oo</caption></image>' );
- expect( blockToolbar.buttonView.isVisible ).to.be.false;
- } );
- it( 'should not display the button when the selection is placed in the root element', () => {
- editor.model.schema.extend( '$text', { allowIn: '$root' } );
- setData( editor.model, '<paragraph>foo</paragraph>[]<paragraph>bar</paragraph>' );
- expect( blockToolbar.buttonView.isVisible ).to.be.false;
- } );
- it( 'should not display the button when all toolbar items are disabled for the selected element', () => {
- const element = document.createElement( 'div' );
- document.body.appendChild( element );
- return ClassicTestEditor.create( element, {
- plugins: [ BlockToolbar, Heading, HeadingButtonsUI, Paragraph, ParagraphButtonUI, Image ],
- blockToolbar: [ 'paragraph', 'heading1', 'heading2' ]
- } ).then( editor => {
- const blockToolbar = editor.plugins.get( BlockToolbar );
- setData( editor.model, '[<image src="/assets/sample.png"></image>]' );
- expect( blockToolbar.buttonView.isVisible ).to.be.false;
- element.remove();
- return editor.destroy();
- } );
- } );
- } );
- describe( 'attaching the button to the content', () => {
- beforeEach( () => {
- // Be sure that window is not scrolled.
- testUtils.sinon.stub( window, 'scrollX' ).get( () => 0 );
- testUtils.sinon.stub( window, 'scrollY' ).get( () => 0 );
- } );
- it( 'should attach the right side of the button to the left side of the editable and center with the first line ' +
- 'of the selected block #1', () => {
- setData( editor.model, '<paragraph>foo[]bar</paragraph>' );
- const target = editor.ui.getEditableElement().querySelector( 'p' );
- const styleMock = testUtils.sinon.stub( window, 'getComputedStyle' );
- styleMock.withArgs( target ).returns( {
- lineHeight: '20px',
- paddingTop: '10px'
- } );
- styleMock.callThrough();
- testUtils.sinon.stub( editor.ui.getEditableElement(), 'getBoundingClientRect' ).returns( {
- left: 200
- } );
- testUtils.sinon.stub( target, 'getBoundingClientRect' ).returns( {
- top: 500,
- left: 300
- } );
- testUtils.sinon.stub( blockToolbar.buttonView.element, 'getBoundingClientRect' ).returns( {
- width: 100,
- height: 100
- } );
- editor.ui.fire( 'update' );
- expect( blockToolbar.buttonView.top ).to.equal( 470 );
- expect( blockToolbar.buttonView.left ).to.equal( 100 );
- } );
- it( 'should attach the right side of the button to the left side of the editable and center with the first line ' +
- 'of the selected block #2', () => {
- setData( editor.model, '<paragraph>foo[]bar</paragraph>' );
- const target = editor.ui.getEditableElement().querySelector( 'p' );
- const styleMock = testUtils.sinon.stub( window, 'getComputedStyle' );
- styleMock.withArgs( target ).returns( {
- lineHeight: 'normal',
- fontSize: '20px',
- paddingTop: '10px'
- } );
- styleMock.callThrough();
- testUtils.sinon.stub( editor.ui.getEditableElement(), 'getBoundingClientRect' ).returns( {
- left: 200
- } );
- testUtils.sinon.stub( target, 'getBoundingClientRect' ).returns( {
- top: 500,
- left: 300
- } );
- testUtils.sinon.stub( blockToolbar.buttonView.element, 'getBoundingClientRect' ).returns( {
- width: 100,
- height: 100
- } );
- editor.ui.fire( 'update' );
- expect( blockToolbar.buttonView.top ).to.equal( 472 );
- expect( blockToolbar.buttonView.left ).to.equal( 100 );
- } );
- it( 'should attach the left side of the button to the right side of the editable when language direction is RTL', () => {
- editor.locale.uiLanguageDirection = 'rtl';
- setData( editor.model, '<paragraph>foo[]bar</paragraph>' );
- const target = editor.ui.getEditableElement().querySelector( 'p' );
- const styleMock = testUtils.sinon.stub( window, 'getComputedStyle' );
- styleMock.withArgs( target ).returns( {
- lineHeight: 'normal',
- fontSize: '20px',
- paddingTop: '10px'
- } );
- styleMock.callThrough();
- testUtils.sinon.stub( editor.ui.getEditableElement(), 'getBoundingClientRect' ).returns( {
- left: 200,
- right: 600
- } );
- testUtils.sinon.stub( target, 'getBoundingClientRect' ).returns( {
- top: 500,
- left: 300
- } );
- testUtils.sinon.stub( blockToolbar.buttonView.element, 'getBoundingClientRect' ).returns( {
- width: 100,
- height: 100
- } );
- editor.ui.fire( 'update' );
- expect( blockToolbar.buttonView.top ).to.equal( 472 );
- expect( blockToolbar.buttonView.left ).to.equal( 600 );
- } );
- describe( 'toolbarView#maxWidth', () => {
- it( 'should be set when the panel shows up', () => {
- expect( blockToolbar.toolbarView.maxWidth ).to.equal( 'auto' );
- blockToolbar.buttonView.fire( 'execute' );
- expect( blockToolbar.panelView.isVisible ).to.be.true;
- expect( blockToolbar.toolbarView.maxWidth ).to.match( /.+px/ );
- } );
- it( 'should be set after the toolbar was shown (but before panel#pin()) to let the items grouping do its job', () => {
- const maxWidthSetSpy = sinon.spy( blockToolbar.toolbarView, 'maxWidth', [ 'set' ] );
- const panelViewShowSpy = sinon.spy( blockToolbar.panelView, 'show' );
- const panelViewPinSpy = sinon.spy( blockToolbar.panelView, 'pin' );
- blockToolbar.buttonView.fire( 'execute' );
- sinon.assert.callOrder( panelViewShowSpy, maxWidthSetSpy.set, panelViewPinSpy );
- } );
- it( 'should set a proper toolbar max-width', () => {
- const viewElement = editor.ui.getEditableElement();
- testUtils.sinon.stub( viewElement, 'getBoundingClientRect' ).returns( {
- left: 100,
- width: 400
- } );
- testUtils.sinon.stub( blockToolbar.buttonView.element, 'getBoundingClientRect' ).returns( {
- left: 60,
- width: 40
- } );
- resizeCallback( [ {
- target: viewElement,
- contentRect: new Rect( viewElement )
- } ] );
- blockToolbar.buttonView.fire( 'execute' );
- // The expected width should be equal the distance between
- // left edge of the block toolbar button and right edge of the editable.
- // ---------------------------
- // | |
- // ____ | |
- // |__| | EDITABLE |
- // button | |
- // | |
- // <--------------max-width------------>
- expect( blockToolbar.toolbarView.maxWidth ).to.equal( '440px' );
- } );
- it( 'should set a proper toolbar max-width in RTL', () => {
- const viewElement = editor.ui.getEditableElement();
- editor.locale.uiLanguageDirection = 'rtl';
- testUtils.sinon.stub( viewElement, 'getBoundingClientRect' ).returns( {
- right: 450,
- width: 400
- } );
- testUtils.sinon.stub( blockToolbar.buttonView.element, 'getBoundingClientRect' ).returns( {
- left: 450,
- width: 40
- } );
- resizeCallback( [ {
- target: viewElement,
- contentRect: new Rect( viewElement )
- } ] );
- blockToolbar.buttonView.fire( 'execute' );
- // The expected width should be equal the distance between
- // left edge of the editable and right edge of the block toolbar button.
- // ---------------------------
- // | |
- // | | ____
- // | EDITABLE | |__|
- // | | button
- // | |
- // <--------------max-width------------>
- expect( blockToolbar.toolbarView.maxWidth ).to.equal( '440px' );
- } );
- } );
- it( 'should reposition the #panelView when open on ui#update', () => {
- blockToolbar.panelView.isVisible = false;
- const spy = testUtils.sinon.spy( blockToolbar.panelView, 'pin' );
- editor.ui.fire( 'update' );
- sinon.assert.notCalled( spy );
- blockToolbar.panelView.isVisible = true;
- editor.ui.fire( 'update' );
- sinon.assert.calledWith( spy, {
- target: blockToolbar.buttonView.element,
- limiter: editor.ui.getEditableElement()
- } );
- } );
- it( 'should not reset the toolbar focus on ui#update', () => {
- blockToolbar.panelView.isVisible = true;
- const spy = testUtils.sinon.spy( blockToolbar.toolbarView, 'focus' );
- editor.ui.fire( 'update' );
- sinon.assert.notCalled( spy );
- } );
- it( 'should hide the open panel on a direct selection change', () => {
- blockToolbar.panelView.isVisible = true;
- editor.model.document.selection.fire( 'change:range', { directChange: true } );
- expect( blockToolbar.panelView.isVisible ).to.be.false;
- } );
- it( 'should not hide the open panel on an indirect selection change', () => {
- blockToolbar.panelView.isVisible = true;
- editor.model.document.selection.fire( 'change:range', { directChange: false } );
- expect( blockToolbar.panelView.isVisible ).to.be.true;
- } );
- it( 'should hide the UI when editor switched to readonly', () => {
- setData( editor.model, '<paragraph>foo[]bar</paragraph>' );
- blockToolbar.buttonView.isVisible = true;
- blockToolbar.panelView.isVisible = true;
- editor.isReadOnly = true;
- expect( blockToolbar.buttonView.isVisible ).to.be.false;
- expect( blockToolbar.panelView.isVisible ).to.be.false;
- } );
- it( 'should show the button when the editor switched back from readonly', () => {
- setData( editor.model, '<paragraph>foo[]bar</paragraph>' );
- expect( blockToolbar.buttonView.isVisible ).to.true;
- editor.isReadOnly = true;
- expect( blockToolbar.buttonView.isVisible ).to.false;
- editor.isReadOnly = false;
- expect( blockToolbar.buttonView.isVisible ).to.be.true;
- } );
- it( 'should show/hide the button on the editor focus/blur', () => {
- setData( editor.model, '<paragraph>foo[]bar</paragraph>' );
- editor.ui.focusTracker.isFocused = true;
- expect( blockToolbar.buttonView.isVisible ).to.true;
- editor.ui.focusTracker.isFocused = false;
- expect( blockToolbar.buttonView.isVisible ).to.false;
- editor.ui.focusTracker.isFocused = true;
- expect( blockToolbar.buttonView.isVisible ).to.true;
- } );
- it( 'should hide the UI when the editor switched to the readonly when the panel is not visible', () => {
- setData( editor.model, '<paragraph>foo[]bar</paragraph>' );
- blockToolbar.buttonView.isVisible = true;
- blockToolbar.panelView.isVisible = false;
- editor.isReadOnly = true;
- expect( blockToolbar.buttonView.isVisible ).to.be.false;
- expect( blockToolbar.panelView.isVisible ).to.be.false;
- } );
- it( 'should update the button position on browser resize only when the button is visible', () => {
- editor.model.schema.extend( '$text', { allowIn: '$root' } );
- const spy = testUtils.sinon.spy( blockToolbar, '_attachButtonToElement' );
- // Place the selection outside of any block because the toolbar will not be shown in this case.
- setData( editor.model, '[]<paragraph>bar</paragraph>' );
- window.dispatchEvent( new Event( 'resize' ) );
- sinon.assert.notCalled( spy );
- setData( editor.model, '<paragraph>ba[]r</paragraph>' );
- spy.resetHistory();
- window.dispatchEvent( new Event( 'resize' ) );
- sinon.assert.called( spy );
- setData( editor.model, '[]<paragraph>bar</paragraph>' );
- spy.resetHistory();
- window.dispatchEvent( new Event( 'resize' ) );
- sinon.assert.notCalled( spy );
- } );
- } );
- describe( 'destroy()', () => {
- it( 'should destroy #resizeObserver if is available', () => {
- const editable = editor.ui.getEditableElement();
- const resizeObserver = new ResizeObserver( editable, () => {} );
- const destroySpy = sinon.spy( resizeObserver, 'destroy' );
- blockToolbar._resizeObserver = resizeObserver;
- blockToolbar.destroy();
- sinon.assert.calledOnce( destroySpy );
- } );
- } );
- } );
|