Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
panr committed Jan 27, 2020
1 parent cd364e1 commit 876553c
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions tests/texttransformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,31 @@ describe( 'Text transformation feature', () => {
} );

describe( 'plugin', () => {
let TextTransformationPlugin, enableWatchersSpy, disableWatchersSpy;
let TextTransformationPlugin;

beforeEach( () => {
TextTransformationPlugin = new TextTransformation( editor );
enableWatchersSpy = sinon.spy( TextTransformationPlugin, '_enableTransformationWatchers' );
disableWatchersSpy = sinon.spy( TextTransformationPlugin, '_disableTransformationWatchers' );

TextTransformationPlugin.init();
return createEditorInstance().then( () => {
TextTransformationPlugin = editor.plugins.get( 'TextTransformation' );
} );
} );

it( 'should be enabled after initialization', () => {
TextTransformationPlugin.init();

expect( TextTransformationPlugin.isEnabled ).to.be.true;
} );

it( 'should initialize watchers after initialization', () => {
sinon.assert.calledOnce( enableWatchersSpy );
} );
const enableWatchersSpy = sinon.spy( TextTransformationPlugin, '_enableTransformationWatchers' );

it( 'should initialize watchers again when is enabled', () => {
sinon.assert.calledOnce( enableWatchersSpy );

TextTransformationPlugin.isEnabled = false;
TextTransformationPlugin.isEnabled = true;
TextTransformationPlugin.init();

sinon.assert.calledTwice( enableWatchersSpy );
expect( TextTransformationPlugin._watchersStack.size ).to.be.at.least( 1 );
sinon.assert.calledOnce( enableWatchersSpy );
} );

it( 'should disable watchers when is disabled', () => {
const disableWatchersSpy = sinon.spy( TextTransformationPlugin, '_disableTransformationWatchers' );

TextTransformationPlugin.isEnabled = false;

sinon.assert.calledOnce( disableWatchersSpy );
Expand Down

0 comments on commit 876553c

Please sign in to comment.