Skip to content

Commit

Permalink
Tests: split unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hub33k committed May 13, 2020
1 parent 8ec41cb commit dd80540
Showing 1 changed file with 63 additions and 6 deletions.
69 changes: 63 additions & 6 deletions tests/core/creators/themedui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
( function() {
'use strict';

// Helper functions
function getEditorContentHeight( editor ) {
return editor.ui.space( 'contents' ).$.offsetHeight;
}
Expand All @@ -12,6 +13,19 @@
return editor.container.$.offsetHeight;
}

function getEditorInnerWidth( editor ) {
return editor.container.findOne( '.cke_inner' ).$.offsetWidth;
}

function getEditorInnerHeight( editor ) {
return editor.container.findOne( '.cke_inner' ).$.offsetHeight;
}

var unitsToTest = [
// absolute lengths
'cm', 'mm', 'q', 'in', 'pc', 'pt', 'px'
];

bender.editor = {
config: {
// Set the empty toolbar, so bazillions of buttons in the build mode will not
Expand Down Expand Up @@ -50,13 +64,9 @@
},

// (#1883)
'test css units': function() {
'test resize event with css units': function() {
var editor = this.editor,
lastResizeData = 0,
unitsToTest = [
// absolute lengths
'cm', 'mm', 'q', 'in', 'pc', 'pt', 'px'
];
lastResizeData = 0;

editor.on( 'resize', function( evt ) {
lastResizeData = evt.data;
Expand All @@ -71,13 +81,60 @@
assert.areSame( CKEDITOR.tools.convertToPx( width ), lastResizeData.outerWidth );
assert.areSame( getEditorContentHeight( editor ), lastResizeData.contentsHeight );
assert.areSame( CKEDITOR.tools.convertToPx( height ), getEditorOuterHeight( editor ) );
}
},

// (#1883)
'test resize event with css units and isContentHeight': function() {
var editor = this.editor,
lastResizeData = 0;

editor.on( 'resize', function( evt ) {
lastResizeData = evt.data;
} );

for ( var i = 0; i < unitsToTest.length; i++ ) {
var width = 20 + unitsToTest[i],
height = 50 + unitsToTest[i];

editor.resize( width, height, true );
assert.areSame( getEditorOuterHeight( editor ), lastResizeData.outerHeight );
assert.areSame( CKEDITOR.tools.convertToPx( width ), lastResizeData.outerWidth );
assert.areSame( getEditorContentHeight( editor ), lastResizeData.contentsHeight );
assert.areSame( CKEDITOR.tools.convertToPx( height ), getEditorContentHeight( editor ) );
}
},

// (#1883)
'test resize event with css units and resizeInner': function() {
var editor = this.editor,
lastResizeData = 0;

editor.on( 'resize', function( evt ) {
lastResizeData = evt.data;
} );

for ( var i = 0; i < unitsToTest.length; i++ ) {
var width = 20 + unitsToTest[i],
height = 50 + unitsToTest[i];

/*
outer
20 cm - 889 px (with 2px border)
50 cm - 1892 px (with 2px border)
inner
756 px
1890 px
*/

editor.resize( width, height, null, true );
console.log(unitsToTest[i], lastResizeData);
assert.areSame( getEditorInnerHeight( editor ), lastResizeData.outerHeight, "1 " + unitsToTest[i] );
assert.areSame( CKEDITOR.tools.convertToPx( width ), lastResizeData.outerWidth, "2 " + unitsToTest[i] );
assert.areSame( getEditorContentHeight( editor ), lastResizeData.contentsHeight, "3 " + unitsToTest[i] );
assert.areSame( CKEDITOR.tools.convertToPx( height ), getEditorInnerHeight( editor ), "4 " + unitsToTest[i] );
}
}
} );
} )();

0 comments on commit dd80540

Please sign in to comment.