|
|
@@ -49,11 +49,11 @@ describe( 'ImageEngine', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should convert with srcset attribute and add sizes attribute', () => {
|
|
|
- setModelData( document, '<image src="foo.png" alt="alt text" srcset="small 148w, big.png 1024w"></image>' );
|
|
|
+ setModelData( document, '<image src="foo.png" alt="alt text" srcset="small.png 148w, big.png 1024w"></image>' );
|
|
|
|
|
|
expect( editor.getData() ).to.equal(
|
|
|
'<figure class="image">' +
|
|
|
- '<img srcset="small 148w, big.png 1024w" sizes="100vw" alt="alt text" src="foo.png">' +
|
|
|
+ '<img srcset="small.png 148w, big.png 1024w" sizes="100vw" alt="alt text" src="foo.png">' +
|
|
|
'</figure>'
|
|
|
);
|
|
|
} );
|
|
|
@@ -187,23 +187,23 @@ describe( 'ImageEngine', () => {
|
|
|
it( 'should convert image with srcset attribute', () => {
|
|
|
editor.setData(
|
|
|
'<figure class="image">' +
|
|
|
- '<img src="foo.png" alt="alt text" srcset="small 148w, big.png 1024w" />' +
|
|
|
+ '<img src="foo.png" alt="alt text" srcset="small.png 148w, big.png 1024w" />' +
|
|
|
'</figure>'
|
|
|
);
|
|
|
|
|
|
expect( getModelData( document, { withoutSelection: true } ) )
|
|
|
- .to.equal( '<image alt="alt text" src="foo.png" srcset="small 148w, big.png 1024w"></image>' );
|
|
|
+ .to.equal( '<image alt="alt text" src="foo.png" srcset="small.png 148w, big.png 1024w"></image>' );
|
|
|
} );
|
|
|
|
|
|
it( 'should ignore sizes attribute', () => {
|
|
|
editor.setData(
|
|
|
'<figure class="image">' +
|
|
|
- '<img src="foo.png" alt="alt text" srcset="small 148w, big.png 1024w" sizes="50vw" />' +
|
|
|
+ '<img src="foo.png" alt="alt text" srcset="small.png 148w, big.png 1024w" sizes="50vw" />' +
|
|
|
'</figure>'
|
|
|
);
|
|
|
|
|
|
expect( getModelData( document, { withoutSelection: true } ) )
|
|
|
- .to.equal( '<image alt="alt text" src="foo.png" srcset="small 148w, big.png 1024w"></image>' );
|
|
|
+ .to.equal( '<image alt="alt text" src="foo.png" srcset="small.png 148w, big.png 1024w"></image>' );
|
|
|
} );
|
|
|
|
|
|
describe( 'should autohoist images', () => {
|
|
|
@@ -385,11 +385,11 @@ describe( 'ImageEngine', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should convert srcset attribute to srcset and sizes', () => {
|
|
|
- setModelData( document, '<image src="foo.png" alt="alt text" srcset="small 148w, big.png 1024w"></image>' );
|
|
|
+ setModelData( document, '<image src="foo.png" alt="alt text" srcset="small.png 148w, big.png 1024w"></image>' );
|
|
|
|
|
|
expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
|
|
|
'<figure class="image ck-widget" contenteditable="false">' +
|
|
|
- '<img alt="alt text" sizes="100vw" src="foo.png" srcset="small 148w, big.png 1024w"></img>' +
|
|
|
+ '<img alt="alt text" sizes="100vw" src="foo.png" srcset="small.png 148w, big.png 1024w"></img>' +
|
|
|
'</figure>'
|
|
|
);
|
|
|
} );
|
|
|
@@ -402,18 +402,20 @@ describe( 'ImageEngine', () => {
|
|
|
}
|
|
|
} )
|
|
|
.then( newEditor => {
|
|
|
- setModelData( newEditor.document, '<image src="foo.png" alt="alt text" srcset="small 148w, big.png 1024w"></image>' );
|
|
|
+ setModelData( newEditor.document,
|
|
|
+ '<image src="foo.png" alt="alt text" srcset="small.png 148w, big.png 1024w"></image>'
|
|
|
+ );
|
|
|
|
|
|
expect( getViewData( newEditor.editing.view, { withoutSelection: true } ) ).to.equal(
|
|
|
'<figure class="image ck-widget" contenteditable="false">' +
|
|
|
- '<img alt="alt text" sizes="50vf" src="foo.png" srcset="small 148w, big.png 1024w"></img>' +
|
|
|
+ '<img alt="alt text" sizes="50vf" src="foo.png" srcset="small.png 148w, big.png 1024w"></img>' +
|
|
|
'</figure>'
|
|
|
);
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
it( 'should remove sizes attribute when srcset attribute is removed', () => {
|
|
|
- setModelData( document, '<image src="foo.png" srcset="small 148w, big.png 1024w"></image>' );
|
|
|
+ setModelData( document, '<image src="foo.png" srcset="small.png 148w, big.png 1024w"></image>' );
|
|
|
const image = document.getRoot().getChild( 0 );
|
|
|
|
|
|
document.enqueueChanges( () => {
|