From e8b0d2d2ad38a81c07196a27274cbd77a9f7905b Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Thu, 4 Nov 2021 13:45:05 +0100 Subject: [PATCH] Tests: Ensured FocusTracker and KeystrokeHandler instances are destroyed. --- .../src/ui/findandreplaceformview.js | 3 ++ .../tests/ui/findandreplaceformview.js | 18 ++++++++++ .../ckeditor5-font/src/ui/colortableview.js | 3 ++ .../ckeditor5-font/tests/ui/colortableview.js | 18 ++++++++++ .../imageinsert/ui/imageinsertpanelview.js | 3 ++ .../ui/textalternativeformview.js | 3 ++ .../imageinsert/ui/imageinsertpanelview.js | 18 ++++++++++ .../ui/textalternativeformview.js | 18 ++++++++++ .../ckeditor5-link/src/ui/linkactionsview.js | 3 ++ .../ckeditor5-link/src/ui/linkformview.js | 3 ++ .../tests/ui/linkactionsview.js | 18 ++++++++++ .../ckeditor5-link/tests/ui/linkformview.js | 18 ++++++++++ .../src/ui/mediaformview.js | 3 ++ .../tests/ui/mediaformview.js | 18 ++++++++++ .../ui/tablecellpropertiesview.js | 3 ++ .../tableproperties/ui/tablepropertiesview.js | 3 ++ .../ui/tablecellpropertiesview.js | 18 ++++++++++ .../tableproperties/ui/tablepropertiesview.js | 18 ++++++++++ .../src/colorgrid/colorgridview.js | 3 ++ .../src/dropdown/button/splitbuttonview.js | 3 ++ .../src/inputtext/inputtextview.js | 3 ++ packages/ckeditor5-ui/src/list/listview.js | 3 ++ .../src/panel/balloon/contextualballoon.js | 14 ++++++++ .../tests/colorgrid/colorgridview.js | 18 ++++++++++ .../tests/dropdown/button/splitbuttonview.js | 18 ++++++++++ .../tests/inputtext/inputtextview.js | 10 ++++++ packages/ckeditor5-ui/tests/list/listview.js | 18 ++++++++++ .../tests/panel/balloon/contextualballoon.js | 34 +++++++++++++++++++ .../ckeditor5-ui/tests/toolbar/toolbarview.js | 16 +++++++++ 29 files changed, 329 insertions(+) diff --git a/packages/ckeditor5-find-and-replace/src/ui/findandreplaceformview.js b/packages/ckeditor5-find-and-replace/src/ui/findandreplaceformview.js index b7725b5ae0a..87d10777730 100644 --- a/packages/ckeditor5-find-and-replace/src/ui/findandreplaceformview.js +++ b/packages/ckeditor5-find-and-replace/src/ui/findandreplaceformview.js @@ -353,6 +353,9 @@ export default class FindAndReplaceFormView extends View { this._initKeystrokeHandling(); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-find-and-replace/tests/ui/findandreplaceformview.js b/packages/ckeditor5-find-and-replace/tests/ui/findandreplaceformview.js index e075d47c64d..d3f7a088359 100644 --- a/packages/ckeditor5-find-and-replace/tests/ui/findandreplaceformview.js +++ b/packages/ckeditor5-find-and-replace/tests/ui/findandreplaceformview.js @@ -673,6 +673,24 @@ describe( 'FindAndReplaceFormView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view._focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view._keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'focus()', () => { it( 'should focus the #findInputView', () => { const spy = sinon.spy( view._findInputView, 'focus' ); diff --git a/packages/ckeditor5-font/src/ui/colortableview.js b/packages/ckeditor5-font/src/ui/colortableview.js index 5eed001c6ac..2649fdff56c 100644 --- a/packages/ckeditor5-font/src/ui/colortableview.js +++ b/packages/ckeditor5-font/src/ui/colortableview.js @@ -235,6 +235,9 @@ export default class ColorTableView extends View { this.keystrokes.listenTo( this.element ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-font/tests/ui/colortableview.js b/packages/ckeditor5-font/tests/ui/colortableview.js index ca23a72c698..e3c2e7367e6 100644 --- a/packages/ckeditor5-font/tests/ui/colortableview.js +++ b/packages/ckeditor5-font/tests/ui/colortableview.js @@ -145,6 +145,24 @@ describe( 'ColorTableView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( colorTableView.focusTracker, 'destroy' ); + + colorTableView.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( colorTableView.keystrokes, 'destroy' ); + + colorTableView.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'focus tracker', () => { it( 'should focus first child of colorTableView in DOM', () => { const spy = sinon.spy( colorTableView._focusCycler, 'focusFirst' ); diff --git a/packages/ckeditor5-image/src/imageinsert/ui/imageinsertpanelview.js b/packages/ckeditor5-image/src/imageinsert/ui/imageinsertpanelview.js index 66d4e1124ef..d0aa826928c 100644 --- a/packages/ckeditor5-image/src/imageinsert/ui/imageinsertpanelview.js +++ b/packages/ckeditor5-image/src/imageinsert/ui/imageinsertpanelview.js @@ -203,6 +203,9 @@ export default class ImageInsertPanelView extends View { }, { priority: 'high' } ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-image/src/imagetextalternative/ui/textalternativeformview.js b/packages/ckeditor5-image/src/imagetextalternative/ui/textalternativeformview.js index b40a184d20b..0fa07b6061b 100644 --- a/packages/ckeditor5-image/src/imagetextalternative/ui/textalternativeformview.js +++ b/packages/ckeditor5-image/src/imagetextalternative/ui/textalternativeformview.js @@ -151,6 +151,9 @@ export default class TextAlternativeFormView extends View { } ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-image/tests/imageinsert/ui/imageinsertpanelview.js b/packages/ckeditor5-image/tests/imageinsert/ui/imageinsertpanelview.js index c02a4d6a556..9d0b3836041 100644 --- a/packages/ckeditor5-image/tests/imageinsert/ui/imageinsertpanelview.js +++ b/packages/ckeditor5-image/tests/imageinsert/ui/imageinsertpanelview.js @@ -271,6 +271,24 @@ describe( 'ImageUploadPanelView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'focus()', () => { it( 'should focus on the first integration', () => { const spy = sinon.spy( view.getIntegration( 'insertImageViaUrl' ), 'focus' ); diff --git a/packages/ckeditor5-image/tests/imagetextalternative/ui/textalternativeformview.js b/packages/ckeditor5-image/tests/imagetextalternative/ui/textalternativeformview.js index 5950bb1a721..b91c4dffe01 100644 --- a/packages/ckeditor5-image/tests/imagetextalternative/ui/textalternativeformview.js +++ b/packages/ckeditor5-image/tests/imagetextalternative/ui/textalternativeformview.js @@ -150,6 +150,24 @@ describe( 'TextAlternativeFormView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'DOM bindings', () => { describe( 'submit event', () => { it( 'should trigger submit event', () => { diff --git a/packages/ckeditor5-link/src/ui/linkactionsview.js b/packages/ckeditor5-link/src/ui/linkactionsview.js index 0b73d2bec48..1da3357bee6 100644 --- a/packages/ckeditor5-link/src/ui/linkactionsview.js +++ b/packages/ckeditor5-link/src/ui/linkactionsview.js @@ -155,6 +155,9 @@ export default class LinkActionsView extends View { this.keystrokes.listenTo( this.element ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-link/src/ui/linkformview.js b/packages/ckeditor5-link/src/ui/linkformview.js index 71ebef56fa6..45decef8ed0 100644 --- a/packages/ckeditor5-link/src/ui/linkformview.js +++ b/packages/ckeditor5-link/src/ui/linkformview.js @@ -200,6 +200,9 @@ export default class LinkFormView extends View { this.keystrokes.listenTo( this.element ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-link/tests/ui/linkactionsview.js b/packages/ckeditor5-link/tests/ui/linkactionsview.js index f2d5387ebfc..054fb652d01 100644 --- a/packages/ckeditor5-link/tests/ui/linkactionsview.js +++ b/packages/ckeditor5-link/tests/ui/linkactionsview.js @@ -199,6 +199,24 @@ describe( 'LinkActionsView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'focus()', () => { it( 'focuses the #previewButtonView', () => { const spy = sinon.spy( view.previewButtonView, 'focus' ); diff --git a/packages/ckeditor5-link/tests/ui/linkformview.js b/packages/ckeditor5-link/tests/ui/linkformview.js index d12f10d43b2..8429d5ca776 100644 --- a/packages/ckeditor5-link/tests/ui/linkformview.js +++ b/packages/ckeditor5-link/tests/ui/linkformview.js @@ -171,6 +171,24 @@ describe( 'LinkFormView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'DOM bindings', () => { describe( 'submit event', () => { it( 'should trigger submit event', () => { diff --git a/packages/ckeditor5-media-embed/src/ui/mediaformview.js b/packages/ckeditor5-media-embed/src/ui/mediaformview.js index 206f67bbb24..7860e9126db 100644 --- a/packages/ckeditor5-media-embed/src/ui/mediaformview.js +++ b/packages/ckeditor5-media-embed/src/ui/mediaformview.js @@ -210,6 +210,9 @@ export default class MediaFormView extends View { }, { priority: 'high' } ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-media-embed/tests/ui/mediaformview.js b/packages/ckeditor5-media-embed/tests/ui/mediaformview.js index 7d5bc62dddb..70e0ab9868d 100644 --- a/packages/ckeditor5-media-embed/tests/ui/mediaformview.js +++ b/packages/ckeditor5-media-embed/tests/ui/mediaformview.js @@ -220,6 +220,24 @@ describe( 'MediaFormView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'DOM bindings', () => { describe( 'submit event', () => { it( 'should trigger submit event', () => { diff --git a/packages/ckeditor5-table/src/tablecellproperties/ui/tablecellpropertiesview.js b/packages/ckeditor5-table/src/tablecellproperties/ui/tablecellpropertiesview.js index dff190cb13d..2c4882d0af5 100644 --- a/packages/ckeditor5-table/src/tablecellproperties/ui/tablecellpropertiesview.js +++ b/packages/ckeditor5-table/src/tablecellproperties/ui/tablecellpropertiesview.js @@ -430,6 +430,9 @@ export default class TableCellPropertiesView extends View { this.keystrokes.listenTo( this.element ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-table/src/tableproperties/ui/tablepropertiesview.js b/packages/ckeditor5-table/src/tableproperties/ui/tablepropertiesview.js index 4cf423bb1b6..f8fb3bc445d 100644 --- a/packages/ckeditor5-table/src/tableproperties/ui/tablepropertiesview.js +++ b/packages/ckeditor5-table/src/tableproperties/ui/tablepropertiesview.js @@ -379,6 +379,9 @@ export default class TablePropertiesView extends View { this.keystrokes.listenTo( this.element ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-table/tests/tablecellproperties/ui/tablecellpropertiesview.js b/packages/ckeditor5-table/tests/tablecellproperties/ui/tablecellpropertiesview.js index 1fa114ca2ce..56a69d75bdd 100644 --- a/packages/ckeditor5-table/tests/tablecellproperties/ui/tablecellpropertiesview.js +++ b/packages/ckeditor5-table/tests/tablecellproperties/ui/tablecellpropertiesview.js @@ -760,6 +760,24 @@ describe( 'table cell properties', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'DOM bindings', () => { describe( 'submit event', () => { it( 'should trigger submit event', () => { diff --git a/packages/ckeditor5-table/tests/tableproperties/ui/tablepropertiesview.js b/packages/ckeditor5-table/tests/tableproperties/ui/tablepropertiesview.js index 01be9ee018f..2510ee92c0f 100644 --- a/packages/ckeditor5-table/tests/tableproperties/ui/tablepropertiesview.js +++ b/packages/ckeditor5-table/tests/tableproperties/ui/tablepropertiesview.js @@ -693,6 +693,24 @@ describe( 'table properties', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'DOM bindings', () => { describe( 'submit event', () => { it( 'should trigger submit event', () => { diff --git a/packages/ckeditor5-ui/src/colorgrid/colorgridview.js b/packages/ckeditor5-ui/src/colorgrid/colorgridview.js index b829d13df0e..ae9a911a09a 100644 --- a/packages/ckeditor5-ui/src/colorgrid/colorgridview.js +++ b/packages/ckeditor5-ui/src/colorgrid/colorgridview.js @@ -176,6 +176,9 @@ export default class ColorGridView extends View { this.keystrokes.listenTo( this.element ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-ui/src/dropdown/button/splitbuttonview.js b/packages/ckeditor5-ui/src/dropdown/button/splitbuttonview.js index 10b14f4b628..58d67118b3b 100644 --- a/packages/ckeditor5-ui/src/dropdown/button/splitbuttonview.js +++ b/packages/ckeditor5-ui/src/dropdown/button/splitbuttonview.js @@ -155,6 +155,9 @@ export default class SplitButtonView extends View { } ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-ui/src/inputtext/inputtextview.js b/packages/ckeditor5-ui/src/inputtext/inputtextview.js index 0a607b0bbcd..2e440d6f5c1 100644 --- a/packages/ckeditor5-ui/src/inputtext/inputtextview.js +++ b/packages/ckeditor5-ui/src/inputtext/inputtextview.js @@ -160,6 +160,9 @@ export default class InputTextView extends View { } ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-ui/src/list/listview.js b/packages/ckeditor5-ui/src/list/listview.js index 79ea475aefa..56d92da22c8 100644 --- a/packages/ckeditor5-ui/src/list/listview.js +++ b/packages/ckeditor5-ui/src/list/listview.js @@ -109,6 +109,9 @@ export default class ListView extends View { this.keystrokes.listenTo( this.element ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-ui/src/panel/balloon/contextualballoon.js b/packages/ckeditor5-ui/src/panel/balloon/contextualballoon.js index 45874a246ec..4318b2edb84 100644 --- a/packages/ckeditor5-ui/src/panel/balloon/contextualballoon.js +++ b/packages/ckeditor5-ui/src/panel/balloon/contextualballoon.js @@ -170,6 +170,17 @@ export default class ContextualBalloon extends Plugin { this._fakePanelsView = this._createFakePanelsView(); } + /** + * @inheritDoc + */ + destroy() { + super.destroy(); + + this.view.destroy(); + this._rotatorView.destroy(); + this._fakePanelsView.destroy(); + } + /** * Returns `true` when the given view is in one of the stacks. Otherwise returns `false`. * @@ -628,6 +639,9 @@ class RotatorView extends View { this.focusTracker.add( this.element ); } + /** + * @inheritDoc + */ destroy() { super.destroy(); diff --git a/packages/ckeditor5-ui/tests/colorgrid/colorgridview.js b/packages/ckeditor5-ui/tests/colorgrid/colorgridview.js index c6f519ff597..4c23bb70100 100644 --- a/packages/ckeditor5-ui/tests/colorgrid/colorgridview.js +++ b/packages/ckeditor5-ui/tests/colorgrid/colorgridview.js @@ -141,6 +141,24 @@ describe( 'ColorGridView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'execute()', () => { it( 'fires event for rendered tiles', () => { const spy = sinon.spy(); diff --git a/packages/ckeditor5-ui/tests/dropdown/button/splitbuttonview.js b/packages/ckeditor5-ui/tests/dropdown/button/splitbuttonview.js index 63302a5c96d..f11692c1d47 100644 --- a/packages/ckeditor5-ui/tests/dropdown/button/splitbuttonview.js +++ b/packages/ckeditor5-ui/tests/dropdown/button/splitbuttonview.js @@ -153,6 +153,24 @@ describe( 'SplitButtonView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'bindings', () => { it( 'delegates actionView#execute to view#execute', () => { const spy = sinon.spy(); diff --git a/packages/ckeditor5-ui/tests/inputtext/inputtextview.js b/packages/ckeditor5-ui/tests/inputtext/inputtextview.js index 200fc7af8ba..92a17934f5d 100644 --- a/packages/ckeditor5-ui/tests/inputtext/inputtextview.js +++ b/packages/ckeditor5-ui/tests/inputtext/inputtextview.js @@ -208,6 +208,16 @@ describe( 'InputTextView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'select()', () => { it( 'should select input value', () => { const selectSpy = sinon.spy( view.element, 'select' ); diff --git a/packages/ckeditor5-ui/tests/list/listview.js b/packages/ckeditor5-ui/tests/list/listview.js index 5c8836045d9..1266db35f25 100644 --- a/packages/ckeditor5-ui/tests/list/listview.js +++ b/packages/ckeditor5-ui/tests/list/listview.js @@ -156,6 +156,24 @@ describe( 'ListView', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'focus()', () => { it( 'focuses the first focusable item in DOM', () => { // No children to focus. diff --git a/packages/ckeditor5-ui/tests/panel/balloon/contextualballoon.js b/packages/ckeditor5-ui/tests/panel/balloon/contextualballoon.js index 75b57fa8b70..91ddabd7663 100644 --- a/packages/ckeditor5-ui/tests/panel/balloon/contextualballoon.js +++ b/packages/ckeditor5-ui/tests/panel/balloon/contextualballoon.js @@ -775,6 +775,30 @@ describe( 'ContextualBalloon', () => { expect( editor.ui.view.body.getIndex( balloon.view ) ).to.not.equal( -1 ); } ); + + it( 'should destroy the #view', () => { + const destroySpy = sinon.spy( balloon.view, 'destroy' ); + + balloon.destroy(); + + sinon.assert.called( destroySpy ); + } ); + + it( 'should destroy the #_rotatorView', () => { + const destroySpy = sinon.spy( balloon._rotatorView, 'destroy' ); + + balloon.destroy(); + + sinon.assert.called( destroySpy ); + } ); + + it( 'should destroy the #_fakePanelsView', () => { + const destroySpy = sinon.spy( balloon._rotatorView, 'destroy' ); + + balloon.destroy(); + + sinon.assert.called( destroySpy ); + } ); } ); describe( 'rotator view', () => { @@ -1083,6 +1107,16 @@ describe( 'ContextualBalloon', () => { } ); } ); + describe( 'destroy()', () => { + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( rotatorView.focusTracker, 'destroy' ); + + rotatorView.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + } ); + describe( 'singleViewMode', () => { it( 'should not display navigation when there is more than one stack', () => { const navigationElement = rotatorView.element.querySelector( '.ck-balloon-rotator__navigation' ); diff --git a/packages/ckeditor5-ui/tests/toolbar/toolbarview.js b/packages/ckeditor5-ui/tests/toolbar/toolbarview.js index 81000a48182..0e3d23f971d 100644 --- a/packages/ckeditor5-ui/tests/toolbar/toolbarview.js +++ b/packages/ckeditor5-ui/tests/toolbar/toolbarview.js @@ -430,6 +430,22 @@ describe( 'ToolbarView', () => { view.destroy(); sinon.assert.calledOnce( view._behavior.destroy ); } ); + + it( 'should destroy the FocusTracker instance', () => { + const destroySpy = sinon.spy( view.focusTracker, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); + + it( 'should destroy the KeystrokeHandler instance', () => { + const destroySpy = sinon.spy( view.keystrokes, 'destroy' ); + + view.destroy(); + + sinon.assert.calledOnce( destroySpy ); + } ); } ); describe( 'focus()', () => {