Skip to content

Commit

Permalink
Refresh unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dumluregn committed Mar 19, 2020
1 parent b582eb5 commit 2fdb658
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 59 deletions.
32 changes: 15 additions & 17 deletions tests/plugins/colorbutton/contentcolors.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/* bender-tags: editor,colorbutton, 1795 */
/* bender-tags: editor,colorbutton,1795 */
/* bender-ckeditor-plugins: colorbutton,undo,toolbar,wysiwygarea */
/* bender-include: _helpers/tools.js */
/* global colorHistoryTools */

( function() {
'use strict';

// bender.editor = true;

bender.test( {
'test color history row exists': function() {
'test color history exists': function() {
bender.editorBot.create( {
name: 'editor1'
}, function( bot ) {
Expand All @@ -20,16 +18,16 @@
bot.setHtmlWithSelection( '[<p>Moo</p>]' );

txtColorBtn.click( editor );
assert.isNotNull( colorHistoryTools.findInPanel( '.cke_colorhistory_row', txtColorBtn ),
'Color history row for txtColor should exist.' );
assert.isNotNull( colorHistoryTools.findInPanel( '.cke_colorhistory', txtColorBtn ),
'Color history for txtColor should exist.' );

bgColorBtn.click( editor );
assert.isNotNull( colorHistoryTools.findInPanel( '.cke_colorhistory_row', bgColorBtn ),
'Color history row for bgColor should exist.' );
assert.isNotNull( colorHistoryTools.findInPanel( '.cke_colorhistory', bgColorBtn ),
'Color history for bgColor should exist.' );
} );
},

'test horizontal rule is hidden and row is empty when there are no colors in content': function() {
'test horizontal rule is visible and row doesn\'t exist when there are no colors in content': function() {
bender.editorBot.create( {
name: 'editor2'
}, function( bot ) {
Expand All @@ -40,16 +38,16 @@
bot.setHtmlWithSelection( '[<p>Moo</p>]' );

txtColorBtn.click( editor );
assert.isFalse( colorHistoryTools.findInPanel( '.cke_colorhistory_separator', txtColorBtn ).isVisible(),
'Horizontal rule for txtColor shouldn\'t be visible.' );
assert.areEqual( 0, colorHistoryTools.findInPanel( '.cke_colorhistory_row', txtColorBtn ).getChildCount(),
'Row for txtColor should be empty.' );
assert.isNotNull( colorHistoryTools.findInPanel( 'hr', txtColorBtn ),
'Horizontal rule for txtColor should be visible.' );
assert.isNull( colorHistoryTools.findInPanel( '.cke_colorhistory_row', txtColorBtn ),
'Row for txtColor shouldn\'t exist.' );

bgColorBtn.click( editor );
assert.isFalse( colorHistoryTools.findInPanel( '.cke_colorhistory_separator', bgColorBtn ).isVisible(),
'Horizontal rule shouldn\'t be visible.' );
assert.areEqual( 0, colorHistoryTools.findInPanel( '.cke_colorhistory_row', bgColorBtn ).getChildCount(),
'Row for bgColor should be empty.' );
assert.isNotNull( colorHistoryTools.findInPanel( 'hr', bgColorBtn ),
'Horizontal rule should be visible.' );
assert.isNull( colorHistoryTools.findInPanel( '.cke_colorhistory_row', bgColorBtn ),
'Row for bgColor shouldn\'t exist.' );
} );
},

Expand Down
44 changes: 3 additions & 41 deletions tests/plugins/colorbutton/customcolors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,7 @@
bender.editor = true;

bender.test( {
'test color history row exists': function() {
var editor = this.editor,
txtColorBtn = editor.ui.get( 'TextColor' ),
bgColorBtn = editor.ui.get( 'BGColor' );

this.editorBot.setHtmlWithSelection( '[<p>Moo</p>]' );

txtColorBtn.click( editor );
assert.isNotNull( colorHistoryTools.findInPanel( '.cke_colorhistory_row', txtColorBtn ),
'Color history row for txtColor should exist.' );

bgColorBtn.click( editor );
assert.isNotNull( colorHistoryTools.findInPanel( '.cke_colorhistory_row', bgColorBtn ),
'Color history row for bgColor should exist.' );
},

'test horizontal rule is hidden and row is empty before any color was chosen': function() {
var editor = this.editor,
txtColorBtn = editor.ui.get( 'TextColor' ),
bgColorBtn = editor.ui.get( 'BGColor' );

this.editorBot.setHtmlWithSelection( '[<p>Moo</p>]' );

txtColorBtn.click( editor );
assert.isFalse( colorHistoryTools.findInPanel( 'hr', txtColorBtn ).isVisible(), 'Horizontal rule shouldn\'t be visible.' );
assert.areEqual( 0, colorHistoryTools.findInPanel( '.cke_colorhistory_row', txtColorBtn ).getChildCount(),
'Row should be empty.' );

bgColorBtn.click( editor );
assert.isFalse( colorHistoryTools.findInPanel( 'hr', bgColorBtn ).isVisible(), 'Horizontal rule shouldn\'t be visible.' );
assert.areEqual( 0, colorHistoryTools.findInPanel( '.cke_colorhistory_row', bgColorBtn ).getChildCount(),
'Row should be empty.' );
},

'test horizontal rule is visible and row is not empty after choosing custom text color': function() {
'test row is not empty after choosing custom text color': function() {
var editor = this.editor,
txtColorBtn = editor.ui.get( 'TextColor' );

Expand All @@ -52,15 +18,14 @@
editor.once( 'dialogHide', function() {
txtColorBtn.click( editor );

assert.isTrue( colorHistoryTools.findInPanel( 'hr', txtColorBtn ).isVisible(), 'Horizontal rule should be visible.' );
assert.areNotEqual( 0, colorHistoryTools.findInPanel( '.cke_colorhistory_row', txtColorBtn ).getChildCount(),
'Row shouldn\'t be empty.' );
} );

colorHistoryTools.chooseColorFromDialog( editor, txtColorBtn, '#33ff33' );
},

'test horizontal rule is visible and row is not empty after choosing custom background color': function() {
'test row is not empty after choosing custom background color': function() {
var editor = this.editor,
bgColorBtn = editor.ui.get( 'BGColor' );

Expand All @@ -69,8 +34,6 @@
editor.once( 'dialogHide', function() {
bgColorBtn.click( editor );

assert.isTrue( colorHistoryTools.findInPanel( '.cke_colorhistory_row', bgColorBtn ).isVisible(),
'Horizontal rule should be visible.' );
assert.areNotEqual( 0, colorHistoryTools.findInPanel( '.cke_colorhistory_row', bgColorBtn ).getChildCount(),
'Row shouldn\'t be empty.' );
} );
Expand All @@ -87,7 +50,6 @@
bender.tools.setHtmlWithSelection( editor, '<p>[Moo]</p>' );
txtColorBtn.click();

assert.isTrue( colorHistoryTools.findInPanel( 'hr', txtColorBtn ).isVisible(), 'Horizontal rule should be visible.' );
assert.areNotEqual( 0, colorHistoryTools.findInPanel( '.cke_colorhistory_row', txtColorBtn ).getChildCount(),
'Row shouldn\'t be empty.' );
} );
Expand Down Expand Up @@ -141,6 +103,6 @@
assert.areEqual( 2, colorHistoryTools.findInPanel( '.cke_colorhistory_row', bgColorBtn ).getChildCount(),
'New background color tile should appear.' );
} );
},
}
} );
} )();
2 changes: 1 addition & 1 deletion tests/plugins/colorbutton/customcolorsasync.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* bender-tags: editor,colorbutton,colordialog,1795 */
/* bender-ckeditor-plugins: colorbutton,colordialog,toolbar */
/* bender-ckeditor-plugins: colorbutton,colordialog,undo,toolbar,wysiwygarea */
/* bender-include: _helpers/tools.js */
/* global colorHistoryTools */

Expand Down

0 comments on commit 2fdb658

Please sign in to comment.