Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge fb54714 into 8f06626
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Jan 15, 2020
2 parents 8f06626 + fb54714 commit 623c228
Showing 1 changed file with 12 additions and 40 deletions.
52 changes: 12 additions & 40 deletions tests/imageresize.js
Expand Up @@ -84,6 +84,18 @@ describe( 'ImageResize', () => {
expect( editor.getData() )
.to.equal( `<figure class="image image_resized" style="width:50%;"><img src="${ IMAGE_SRC_FIXTURE }"></figure>` );
} );

it( 'doesn\'t downcast consumed tokens', () => {
editor.conversion.for( 'downcast' ).add( dispatcher =>
dispatcher.on( 'attribute:width:image', ( evt, data, conversionApi ) => {
conversionApi.consumable.consume( data.item, 'attribute:width:image' );
}, { priority: 'high' } )
);
setData( editor.model, `<image src="${ IMAGE_SRC_FIXTURE }" width="50%"></image>` );

expect( editor.getData() )
.to.equal( `<figure class="image"><img src="${ IMAGE_SRC_FIXTURE }"></figure>` );
} );
} );

describe( 'schema', () => {
Expand Down Expand Up @@ -667,46 +679,6 @@ describe( 'ImageResize', () => {
}
} );

// TODO move to Resizer tests.
describe( 'Resizer', () => {
beforeEach( () => createEditor() );

it( 'uses rounded (int) values', async () => {
setData( editor.model, `<paragraph>foo</paragraph>[<image src="${ IMAGE_SRC_FIXTURE }"></image>]` );

widget = viewDocument.getRoot().getChild( 1 );

await generateResizeTest( {
expectedWidth: 97,
// Makes it resize the image to 97.2188px, unless there's a rounding.
pointerOffset: {
x: 7.3,
y: -1
},
resizerPosition: 'bottom-left',
checkBeforeMouseUp( domFigure, domResizeWrapper ) {
expect( domFigure.style.width ).to.match( /^\d\dpx$/ );
expect( domResizeWrapper.style.width ).to.match( /^\d\dpx$/ );
}
} )();

expect( editor.model.document.getRoot().getChild( 1 ).getAttribute( 'width' ) ).to.match( /^\d\dpx$/ );
} );

it( 'hides the resize wrapper when its disabled', () => {
setData( editor.model, `<paragraph>foo</paragraph>[<image src="${ IMAGE_SRC_FIXTURE }"></image>]` );

const resizer = getSelectedImageResizer( editor );
const resizerWrapper = editor.ui.getEditableElement().querySelector( '.ck-widget__resizer' );

expect( resizerWrapper.style.display ).to.equal( '' );

resizer.isEnabled = false;

expect( resizerWrapper.style.display ).to.equal( 'none' );
} );
} );

describe( 'widget toolbar integration', () => {
let widgetToolbarRepository;

Expand Down

0 comments on commit 623c228

Please sign in to comment.