|
|
@@ -17,34 +17,16 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
describe( 'utils', () => {
|
|
|
testUtils.createSinonSandbox();
|
|
|
|
|
|
- describe( 'color and background color related', () => {
|
|
|
- it( 'plugin names has proper values', () => {
|
|
|
- expect( FONT_COLOR ).to.equal( 'fontColor' );
|
|
|
- expect( FONT_BACKGROUND_COLOR ).to.equal( 'fontBackgroundColor' );
|
|
|
- } );
|
|
|
+ it( 'plugin names has proper values', () => {
|
|
|
+ expect( FONT_COLOR ).to.equal( 'fontColor' );
|
|
|
+ expect( FONT_BACKGROUND_COLOR ).to.equal( 'fontBackgroundColor' );
|
|
|
+ } );
|
|
|
|
|
|
- it( 'normalizeColorOptions() can produce the same output object', () => {
|
|
|
- const normalizedArray = normalizeColorOptions( [
|
|
|
- 'black',
|
|
|
- {
|
|
|
- color: 'black'
|
|
|
- },
|
|
|
- {
|
|
|
- color: 'black',
|
|
|
- label: 'Black'
|
|
|
- },
|
|
|
- {
|
|
|
- color: 'black',
|
|
|
- label: 'Black',
|
|
|
- hasBorder: true
|
|
|
- },
|
|
|
- {
|
|
|
- color: 'black',
|
|
|
- hasBorder: true
|
|
|
- }
|
|
|
- ] );
|
|
|
+ describe( 'normalizeColorOptions()', () => {
|
|
|
+ it( 'should return normalized config object from string', () => {
|
|
|
+ const normalizedOption = normalizeColorOptions( [ 'black' ] );
|
|
|
|
|
|
- expect( normalizedArray ).to.deep.equal( [
|
|
|
+ expect( normalizedOption ).to.deep.equal( [
|
|
|
{
|
|
|
model: 'black',
|
|
|
label: 'black',
|
|
|
@@ -55,7 +37,14 @@ describe( 'utils', () => {
|
|
|
color: 'black'
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
+ ] );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should return normalized config object from object( color )', () => {
|
|
|
+ const normalizedOption = normalizeColorOptions( [ { color: 'black' } ] );
|
|
|
+
|
|
|
+ expect( normalizedOption ).to.deep.equal( [
|
|
|
{
|
|
|
model: 'black',
|
|
|
label: 'black',
|
|
|
@@ -66,7 +55,19 @@ describe( 'utils', () => {
|
|
|
color: 'black'
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
+ ] );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should return normalized config object from object( color, label )', () => {
|
|
|
+ const normalizedOption = normalizeColorOptions( [
|
|
|
+ {
|
|
|
+ color: 'black',
|
|
|
+ label: 'Black'
|
|
|
+ }
|
|
|
+ ] );
|
|
|
+
|
|
|
+ expect( normalizedOption ).to.deep.equal( [
|
|
|
{
|
|
|
model: 'black',
|
|
|
label: 'Black',
|
|
|
@@ -77,7 +78,20 @@ describe( 'utils', () => {
|
|
|
color: 'black'
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
+ ] );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should return normalized config object from object( color, label, hasBorder )', () => {
|
|
|
+ const normalizedOption = normalizeColorOptions( [
|
|
|
+ {
|
|
|
+ color: 'black',
|
|
|
+ label: 'Black',
|
|
|
+ hasBorder: true
|
|
|
+ }
|
|
|
+ ] );
|
|
|
+
|
|
|
+ expect( normalizedOption ).to.deep.equal( [
|
|
|
{
|
|
|
model: 'black',
|
|
|
label: 'Black',
|
|
|
@@ -88,7 +102,19 @@ describe( 'utils', () => {
|
|
|
color: 'black'
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
+ ] );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should return normalized config object from object( color, hasBorder )', () => {
|
|
|
+ const normalizedOption = normalizeColorOptions( [
|
|
|
+ {
|
|
|
+ color: 'black',
|
|
|
+ hasBorder: true
|
|
|
+ }
|
|
|
+ ] );
|
|
|
+
|
|
|
+ expect( normalizedOption ).to.deep.equal( [
|
|
|
{
|
|
|
model: 'black',
|
|
|
label: 'black',
|
|
|
@@ -99,47 +125,47 @@ describe( 'utils', () => {
|
|
|
color: 'black'
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
] );
|
|
|
} );
|
|
|
+ } );
|
|
|
|
|
|
- it( 'addColorTableToDropdown()', () => {
|
|
|
- const dropdown = createDropdown();
|
|
|
- dropdown.render();
|
|
|
-
|
|
|
- addColorTableToDropdown( {
|
|
|
- dropdownView: dropdown,
|
|
|
- colors: [
|
|
|
- {
|
|
|
- label: 'Black',
|
|
|
- color: '#000',
|
|
|
- options: {
|
|
|
- hasBorder: false
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: 'White',
|
|
|
- color: '#FFFFFF',
|
|
|
- options: {
|
|
|
- hasBorder: true
|
|
|
- }
|
|
|
- }
|
|
|
- ],
|
|
|
- columns: 2,
|
|
|
- removeButtonTooltip: 'Remove Color'
|
|
|
- } );
|
|
|
+ it( 'addColorTableToDropdown()', () => {
|
|
|
+ const dropdown = createDropdown();
|
|
|
+ dropdown.render();
|
|
|
|
|
|
- expect( dropdown.colorTableView ).to.be.instanceOf( ColorTableView );
|
|
|
- expect( dropdown.panelView.children.length ).to.equal( 1 );
|
|
|
+ addColorTableToDropdown( {
|
|
|
+ dropdownView: dropdown,
|
|
|
+ colors: [
|
|
|
+ {
|
|
|
+ label: 'Black',
|
|
|
+ color: '#000',
|
|
|
+ options: {
|
|
|
+ hasBorder: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'White',
|
|
|
+ color: '#FFFFFF',
|
|
|
+ options: {
|
|
|
+ hasBorder: true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ columns: 2,
|
|
|
+ removeButtonTooltip: 'Remove Color'
|
|
|
} );
|
|
|
|
|
|
- it( 'renderDowncastElement()', () => {
|
|
|
- const testRender = renderDowncastElement( 'color' );
|
|
|
- const fake = testUtils.sinon.fake();
|
|
|
+ expect( dropdown.colorTableView ).to.be.instanceOf( ColorTableView );
|
|
|
+ expect( dropdown.panelView.children.length ).to.equal( 1 );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'renderDowncastElement()', () => {
|
|
|
+ const testRender = renderDowncastElement( 'color' );
|
|
|
+ const fake = testUtils.sinon.fake();
|
|
|
|
|
|
- testRender( 'blue', { createAttributeElement: fake } );
|
|
|
+ testRender( 'blue', { createAttributeElement: fake } );
|
|
|
|
|
|
- sinon.assert.calledWithExactly( fake, 'span', { style: 'color:blue' }, { priority: 7 } );
|
|
|
- } );
|
|
|
+ sinon.assert.calledWithExactly( fake, 'span', { style: 'color:blue' }, { priority: 7 } );
|
|
|
} );
|
|
|
} );
|