From 2e44ec94f3bc356b0b9ea632671c44b1c59f3771 Mon Sep 17 00:00:00 2001 From: hub33k Date: Tue, 9 Jun 2020 12:06:56 +0200 Subject: [PATCH] Tests: add unit test (widget - keystroke). --- tests/plugins/widget/keystroke.js | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/plugins/widget/keystroke.js diff --git a/tests/plugins/widget/keystroke.js b/tests/plugins/widget/keystroke.js new file mode 100644 index 00000000000..b35587fb124 --- /dev/null +++ b/tests/plugins/widget/keystroke.js @@ -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 ); + } + } ); +} )();