Skip to content

Commit

Permalink
Tests: add unit test (widget - keystroke).
Browse files Browse the repository at this point in the history
  • Loading branch information
hub33k committed Jun 9, 2020
1 parent 311aec8 commit 2e44ec9
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/plugins/widget/keystroke.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* bender-tags: widgetcore, 3998 */
/* bender-ckeditor-plugins: wysiwygarea,sourcearea,widget */

( function() {
'use strict';

function pressCtrlEnter( editor ) {
editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { keyCode: CKEDITOR.CTRL + 13 } ) );
}

bender.editor = {
config: {
keystrokes: [
[ CKEDITOR.CTRL + 13 /*Enter*/, 'source' ]
]
}
};

bender.test( {
// (#3998)
'test change wysiwyg mode to source mode by pressing keystroke': function() {
var editor = this.editor;

assert.areSame( 'wysiwyg', editor.mode, 'Wysiwyg mode is active at start.' );
pressCtrlEnter( editor );
assert.areSame( 'source', editor.mode, 'Source mode is active (changed from wysiwyg mode).' );
},

// (#3998)
'test change source mode to wysiwyg mode by pressing keystroke': function() {
var editor = this.editor;

assert.areSame( 'source', editor.mode, 'Source mode is active at start.' );
pressCtrlEnter( editor );
wait( function() {
assert.areSame( 'wysiwyg', editor.mode, 'Wysiwyg mode is active (changed from wysiwyg mode).' );
}, 100 );
}
} );
} )();

0 comments on commit 2e44ec9

Please sign in to comment.