Skip to content

Commit

Permalink
Adding unit and manual tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Samsel committed Jun 30, 2017
1 parent 82cbcda commit df8a63b
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 0 deletions.
121 changes: 121 additions & 0 deletions tests/plugins/colordialog/colordialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/* bender-tags: editor */
/* bender-ckeditor-plugins: colordialog,wysiwygarea */

( function() {
'use strict';

bender.editor = {};

var test = {
'test colordialog add hash to colors 6 digits': function() {
var editor = this.editor;

editor.once( 'dialogShow', function( evt ) {
var dialog = evt.data;
dialog.setValueOf( 'picker', 'selectedColor', '123456' );
dialog.getButton( 'ok' ).click();

} );

editor.getColorFromDialog( function( color ) {
resume( function() {
assert.areSame( '#123456', color );
} );
} );
wait();
},

'test colordialog add hash to colors 3 digits': function() {
var editor = this.editor;

editor.once( 'dialogShow', function( evt ) {
var dialog = evt.data;
dialog.setValueOf( 'picker', 'selectedColor', 'FDE' );
dialog.getButton( 'ok' ).click();

} );

editor.getColorFromDialog( function( color ) {
resume( function() {
assert.areSame( '#FDE', color );
} );
} );
wait();
},

'test colordialog does not add hash 1 digit': function() {
var editor = this.editor;

editor.once( 'dialogShow', function( evt ) {
var dialog = evt.data;
dialog.setValueOf( 'picker', 'selectedColor', '3' );
dialog.getButton( 'ok' ).click();

} );

editor.getColorFromDialog( function( color ) {
resume( function() {
assert.areSame( '3', color );
} );
} );
wait();
},

'test colordialog does not add hash color name': function() {
var editor = this.editor;

editor.once( 'dialogShow', function( evt ) {
var dialog = evt.data;
dialog.setValueOf( 'picker', 'selectedColor', 'red' );
dialog.getButton( 'ok' ).click();

} );

editor.getColorFromDialog( function( color ) {
resume( function() {
assert.areSame( 'red', color );
} );
} );
wait();
},

'test colordialog does not add hash rgb': function() {
var editor = this.editor;

editor.once( 'dialogShow', function( evt ) {
var dialog = evt.data;
dialog.setValueOf( 'picker', 'selectedColor', 'rgb(10, 20, 30)' );
dialog.getButton( 'ok' ).click();

} );

editor.getColorFromDialog( function( color ) {
resume( function() {
assert.areSame( 'rgb(10, 20, 30)', color );
} );
} );
wait();
},

'test colordialog does not add hash empty value': function() {
var editor = this.editor;

editor.once( 'dialogShow', function( evt ) {
var dialog = evt.data;
dialog.setValueOf( 'picker', 'selectedColor', '' );
dialog.getButton( 'ok' ).click();

} );

editor.getColorFromDialog( function( color ) {
resume( function() {
assert.areSame( '', color );
} );
} );
wait();
}
};

bender.test( test );

} )();
15 changes: 15 additions & 0 deletions tests/plugins/colordialog/manual/addhash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<textarea id='editor1'>
<table border="1" cellspacing="1" cellpadding="1">
<tr>
<td>Cell 1</td><td>Cell 2</td>
</tr>
</table>
</textarea>

<script>
if ( bender.tools.env.mobile ) {
bender.ignore();
} else {
CKEDITOR.replace( 'editor1' );
}
</script>
13 changes: 13 additions & 0 deletions tests/plugins/colordialog/manual/addhash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@bender-tags: tc, feature, colordialog, 565, 4.8.0
@bender-ui: collapsed
@bender-ckeditor-plugins: table,tabletools,colordialog,toolbar,wysiwygarea,sourcearea,contextmenu

1. Right click into table cell.
1. Select `Cell -> Cell Properties`.
1. Choose background color.
1. Type color in hexadecimal 6-digit format **without** leading `#`. E.g. (`ABC123`).
1. Confirm it.
1. Inseted color should contain additional `#` at the beginning.
1. Repeat above steps for color with hexadecimal 3-digits format. E.g. (`FFF`).

Note: You can also check some wrong situations.

0 comments on commit df8a63b

Please sign in to comment.