/** * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ /* global document */ import Font from '../src/font'; import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset'; import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor'; import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; describe( 'Integration test Font', () => { let element, editor, model; beforeEach( () => { element = document.createElement( 'div' ); document.body.appendChild( element ); return ClassicTestEditor .create( element, { plugins: [ Font, ArticlePluginSet ], image: { toolbar: [ 'imageStyle:full', 'imageStyle:side' ] } } ) .then( newEditor => { editor = newEditor; model = editor.model; } ); } ); afterEach( () => { element.remove(); return editor.destroy(); } ); describe( 'in-between font plugin features', () => { it( 'should render one span element for all types of font features', () => { setModelData( model, '' + '<$text fontColor="#123456" fontBackgroundColor="rgb(10,20,30)" fontSize="big" ' + 'fontFamily="Arial, Helvetica, sans-serif">foo' + '' ); expect( editor.getData() ).to.equal( '

' + 'foo' + '' + '

' ); } ); it( 'should render one span element for all types of font features (supportAllValues=true)', () => { const element = document.createElement( 'div' ); document.body.appendChild( element ); return ClassicTestEditor .create( element, { plugins: [ Font, ArticlePluginSet ], fontFamily: { supportAllValues: true }, fontSize: { options: [ 10, 12, 14 ], supportAllValues: true }, image: { toolbar: [ 'imageStyle:full', 'imageStyle:side' ] } } ) .then( editor => { const model = editor.model; setModelData( model, '' + '<$text fontColor="#123456" fontBackgroundColor="rgb(10,20,30)" ' + 'fontSize="48px" fontFamily="docs-Roboto"' + '>foo' + '' + '' ); expect( editor.getData() ).to.equal( '

' + 'foo' + '' + '

' ); return editor.destroy(); } ) .then( () => { element.remove(); } ); } ); } ); describe( 'between font plugin and other', () => { it( 'should render elements wrapped in proper order', () => { setModelData( model, '' + '<$text bold="true" linkHref="foo" fontColor="red" fontSize="big">foo' + '' ); expect( editor.getData() ).to.equal( '

' + '' + '' + 'foo' + '' + '' + '

' ); } ); it( 'should render elements wrapped in proper order (supportAllValues=true)', () => { const element = document.createElement( 'div' ); document.body.appendChild( element ); return ClassicTestEditor .create( element, { plugins: [ Font, ArticlePluginSet ], fontFamily: { supportAllValues: true }, fontSize: { options: [ 10, 12, 14 ], supportAllValues: true }, image: { toolbar: [ 'imageStyle:full', 'imageStyle:side' ] } } ) .then( editor => { const model = editor.model; setModelData( model, '' + '<$text bold="true" linkHref="foo" fontColor="red" fontSize="18px">foo' + '' ); expect( editor.getData() ).to.equal( '

' + '' + '' + 'foo' + '' + '' + '

' ); return editor.destroy(); } ) .then( () => { element.remove(); } ); } ); } ); } );