Skip to content

Commit

Permalink
Tests: Ensured FocusTracker and KeystrokeHandler instances are destro…
Browse files Browse the repository at this point in the history
…yed.
  • Loading branch information
oleq committed Nov 4, 2021
1 parent 5144be2 commit e8b0d2d
Show file tree
Hide file tree
Showing 29 changed files with 329 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ export default class FindAndReplaceFormView extends View {
this._initKeystrokeHandling();
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
3 changes: 3 additions & 0 deletions packages/ckeditor5-font/src/ui/colortableview.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ export default class ColorTableView extends View {
this.keystrokes.listenTo( this.element );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
18 changes: 18 additions & 0 deletions packages/ckeditor5-font/tests/ui/colortableview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ export default class ImageInsertPanelView extends View {
}, { priority: 'high' } );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ export default class TextAlternativeFormView extends View {
} );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/ckeditor5-link/src/ui/linkactionsview.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export default class LinkActionsView extends View {
this.keystrokes.listenTo( this.element );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
3 changes: 3 additions & 0 deletions packages/ckeditor5-link/src/ui/linkformview.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ export default class LinkFormView extends View {
this.keystrokes.listenTo( this.element );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
18 changes: 18 additions & 0 deletions packages/ckeditor5-link/tests/ui/linkactionsview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
18 changes: 18 additions & 0 deletions packages/ckeditor5-link/tests/ui/linkformview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/ckeditor5-media-embed/src/ui/mediaformview.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ export default class MediaFormView extends View {
}, { priority: 'high' } );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
18 changes: 18 additions & 0 deletions packages/ckeditor5-media-embed/tests/ui/mediaformview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ export default class TableCellPropertiesView extends View {
this.keystrokes.listenTo( this.element );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ export default class TablePropertiesView extends View {
this.keystrokes.listenTo( this.element );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/ckeditor5-ui/src/colorgrid/colorgridview.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ export default class ColorGridView extends View {
this.keystrokes.listenTo( this.element );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
3 changes: 3 additions & 0 deletions packages/ckeditor5-ui/src/dropdown/button/splitbuttonview.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export default class SplitButtonView extends View {
} );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
3 changes: 3 additions & 0 deletions packages/ckeditor5-ui/src/inputtext/inputtextview.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ export default class InputTextView extends View {
} );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
3 changes: 3 additions & 0 deletions packages/ckeditor5-ui/src/list/listview.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export default class ListView extends View {
this.keystrokes.listenTo( this.element );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
14 changes: 14 additions & 0 deletions packages/ckeditor5-ui/src/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*
Expand Down Expand Up @@ -628,6 +639,9 @@ class RotatorView extends View {
this.focusTracker.add( this.element );
}

/**
* @inheritDoc
*/
destroy() {
super.destroy();

Expand Down
Loading

0 comments on commit e8b0d2d

Please sign in to comment.