Skip to content

Commit

Permalink
Review fix: adding unit test for default css for inlinetoolbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Samsel committed Nov 15, 2017
1 parent 80bd873 commit 736abe7
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/plugins/inlinetoolbar/cssdefault.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* bender-tags: inlinetoolbar */
/* bender-ckeditor-plugins: toolbar,inlinetoolbar,basicstyles */

( function() {
'use strict';
// Please be aware that entire test suite has to use the same skin. That's why tests are separate between 2 files.

bender.editors = {
classic: {
name: 'editor1',
creator: 'replace',
startupData: '<p>Hello World</p>',
config: {
skin: 'moono'
}
},
divarea: {
name: 'divarea',
creator: 'replace',
startupData: '<p>Hello World</p>',
config: {
skin: 'moono',
extraPlugins: 'divarea'
}
},
inline: {
name: 'inline',
creator: 'inline',
startupData: '<p>Hello World</p>',
config: {
skin: 'moono'
}
}
};

// We need to set up skin at the very beginning befor files start to load.
CKEDITOR.skinName = 'moono';

// Overwrite prototype to simulate missing css file.
var oldFn = CKEDITOR.dom.document.prototype.appendStyleSheet;
CKEDITOR.dom.document.prototype.appendStyleSheet = function( cssFileUrl ) {
// Simualate missing css in skin.
if ( cssFileUrl.indexOf( 'inlinetoolbar.css' ) > -1 || cssFileUrl.indexOf( 'balloonpanel.css' ) > -1 ) {
cssFileUrl = '';
}
oldFn.call( CKEDITOR.document, cssFileUrl );
};

var tests = {
'test check default css usage': function( editor ) {

var panel = new CKEDITOR.ui.inlineToolbar( editor );
panel.addItems( {
bold: new CKEDITOR.ui.button( {
label: 'test',
command: 'bold'
} )
} );
panel.attach( editor.editable().findOne( 'p' ) );
assert.areSame( 'rgb(248, 248, 248)', panel._view.parts.panel.getComputedStyle( 'background-color' ),
'Default skin background color seems to be incorrect.' );
}
};

tests = bender.tools.createTestsForEditors( CKEDITOR.tools.objectKeys( bender.editors ), tests );
bender.test( tests );
} )();
57 changes: 57 additions & 0 deletions tests/plugins/inlinetoolbar/cssskin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* bender-tags: inlinetoolbar */
/* bender-ckeditor-plugins: toolbar,inlinetoolbar,basicstyles */

( function() {
'use strict';
// Please be aware that entire test suite has to use the same skin. That's why tests are separate between 2 files.

bender.editors = {
classic: {
name: 'editor1',
creator: 'replace',
startupData: '<p>Hello World</p>',
config: {
skin: 'moono'
}
},
divarea: {
name: 'divarea',
creator: 'replace',
startupData: '<p>Hello World</p>',
config: {
skin: 'moono',
extraPlugins: 'divarea'
}
},
inline: {
name: 'inline',
creator: 'inline',
startupData: '<p>Hello World</p>',
config: {
skin: 'moono'
}
}
};

// We need to set up skin at the very beginning befor files start to load.
CKEDITOR.skinName = 'moono';

var tests = {
'test check default css usage': function( editor ) {

var panel = new CKEDITOR.ui.inlineToolbar( editor );
panel.addItems( {
bold: new CKEDITOR.ui.button( {
label: 'test',
command: 'bold'
} )
} );
panel.attach( editor.editable().findOne( 'p' ) );
assert.areSame( 'rgba(0, 0, 0, 0)', panel._view.parts.panel.getComputedStyle( 'background-color' ),
'Background color seems to be incorrect.' );
}
};

tests = bender.tools.createTestsForEditors( CKEDITOR.tools.objectKeys( bender.editors ), tests );
bender.test( tests );
} )();

0 comments on commit 736abe7

Please sign in to comment.