/** * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor'; import ImageResizeCommand from '../../src/imageresize/imageresizecommand'; import { setData, getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; describe( 'ImageStyleCommand', () => { let model, command; beforeEach( () => { return ModelTestEditor.create() .then( newEditor => { model = newEditor.model; command = new ImageResizeCommand( newEditor ); model.schema.register( 'p', { inheritAllFrom: '$block' } ); model.schema.register( 'image', { isObject: true, isBlock: true, allowWhere: '$block', allowAttributes: 'width' } ); } ); } ); describe( '#isEnabled', () => { it( 'is true when image is selected', () => { setData( model, '
x
[x
' ); expect( command ).to.have.property( 'isEnabled', true ); } ); it( 'is false when image is not selected', () => { setData( model, 'x[]
x
[x[]
x
[x
' ); expect( command ).to.have.deep.property( 'value', { width: '50px', height: null } ); } ); it( 'is set to null if image does not have the width set', () => { setData( model, 'x
[x
' ); expect( command ).to.have.property( 'value', null ); } ); } ); describe( 'execute()', () => { it( 'sets image width', () => { setData( model, '[