| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- /**
- * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- import {
- FONT_COLOR,
- FONT_BACKGROUND_COLOR,
- normalizeColorOptions,
- addColorTableToDropdown
- } from './../src/utils';
- import { createDropdown } from '@ckeditor/ckeditor5-ui/src/dropdown/utils';
- import ColorTableView from './../src/ui/colortableview';
- describe( 'utils', () => {
- 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( '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
- }
- ] );
- expect( normalizedArray ).to.deep.equal( [
- {
- model: 'black',
- label: 'black',
- hasBorder: false,
- view: {
- name: 'span',
- styles: {
- color: 'black'
- }
- }
- },
- {
- model: 'black',
- label: 'black',
- hasBorder: false,
- view: {
- name: 'span',
- styles: {
- color: 'black'
- }
- }
- },
- {
- model: 'black',
- label: 'Black',
- hasBorder: false,
- view: {
- name: 'span',
- styles: {
- color: 'black'
- }
- }
- },
- {
- model: 'black',
- label: 'Black',
- hasBorder: true,
- view: {
- name: 'span',
- styles: {
- color: 'black'
- }
- }
- },
- {
- model: 'black',
- label: 'black',
- hasBorder: true,
- view: {
- name: 'span',
- styles: {
- color: 'black'
- }
- }
- },
- ] );
- } );
- it( 'adding colors table to dropdown works', () => {
- 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'
- } );
- expect( dropdown.colorTableView ).to.be.instanceOf( ColorTableView );
- expect( dropdown.panelView.children.length ).to.equal( 1 );
- } );
- } );
- } );
|