|
@@ -217,6 +217,20 @@ describe( 'ImageUploadEditing', () => {
|
|
|
expect( getModelData( model ) ).to.equal( '<paragraph>foo[]</paragraph>' );
|
|
expect( getModelData( model ) ).to.equal( '<paragraph>foo[]</paragraph>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ it( 'should not insert image when file is null', () => {
|
|
|
|
|
+ const viewDocument = editor.editing.view.document;
|
|
|
|
|
+ const dataTransfer = new DataTransfer( { files: [ null ], types: [ 'Files' ] } );
|
|
|
|
|
+
|
|
|
|
|
+ setModelData( model, '<paragraph>foo[]</paragraph>' );
|
|
|
|
|
+
|
|
|
|
|
+ const targetRange = doc.selection.getFirstRange();
|
|
|
|
|
+ const targetViewRange = editor.editing.mapper.toViewRange( targetRange );
|
|
|
|
|
+
|
|
|
|
|
+ viewDocument.fire( 'clipboardInput', { dataTransfer, targetRanges: [ targetViewRange ] } );
|
|
|
|
|
+
|
|
|
|
|
+ expect( getModelData( model ) ).to.equal( '<paragraph>foo[]</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
it( 'should not insert image when there is non-empty HTML content pasted', () => {
|
|
it( 'should not insert image when there is non-empty HTML content pasted', () => {
|
|
|
const fileMock = createNativeFileMock();
|
|
const fileMock = createNativeFileMock();
|
|
|
const dataTransfer = new DataTransfer( {
|
|
const dataTransfer = new DataTransfer( {
|
|
@@ -314,7 +328,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
it( 'should use read data once it is present', done => {
|
|
it( 'should use read data once it is present', done => {
|
|
|
const file = createNativeFileMock();
|
|
const file = createNativeFileMock();
|
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
|
|
|
model.once( '_change', () => {
|
|
model.once( '_change', () => {
|
|
|
expect( getViewData( view ) ).to.equal(
|
|
expect( getViewData( view ) ).to.equal(
|
|
@@ -334,7 +348,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
it( 'should replace read data with server response once it is present', done => {
|
|
it( 'should replace read data with server response once it is present', done => {
|
|
|
const file = createNativeFileMock();
|
|
const file = createNativeFileMock();
|
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
|
|
|
model.document.once( 'change', () => {
|
|
model.document.once( 'change', () => {
|
|
|
model.document.once( 'change', () => {
|
|
model.document.once( 'change', () => {
|
|
@@ -365,7 +379,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
}, { priority: 'high' } );
|
|
}, { priority: 'high' } );
|
|
|
|
|
|
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
|
|
|
nativeReaderMock.mockError( 'Reading error.' );
|
|
nativeReaderMock.mockError( 'Reading error.' );
|
|
|
} );
|
|
} );
|
|
@@ -381,7 +395,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
}, { priority: 'high' } );
|
|
}, { priority: 'high' } );
|
|
|
|
|
|
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
nativeReaderMock.abort();
|
|
nativeReaderMock.abort();
|
|
|
|
|
|
|
|
setTimeout( () => {
|
|
setTimeout( () => {
|
|
@@ -405,7 +419,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
|
|
|
sinon.assert.calledOnce( loadSpy );
|
|
sinon.assert.calledOnce( loadSpy );
|
|
|
|
|
|
|
@@ -442,7 +456,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
evt.stop();
|
|
evt.stop();
|
|
|
}, { priority: 'high' } );
|
|
}, { priority: 'high' } );
|
|
|
|
|
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
|
|
|
model.document.once( 'change', () => {
|
|
model.document.once( 'change', () => {
|
|
|
model.document.once( 'change', () => {
|
|
model.document.once( 'change', () => {
|
|
@@ -459,7 +473,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
it( 'should abort upload if image is removed', () => {
|
|
it( 'should abort upload if image is removed', () => {
|
|
|
const file = createNativeFileMock();
|
|
const file = createNativeFileMock();
|
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
|
|
|
const abortSpy = testUtils.sinon.spy( loader, 'abort' );
|
|
const abortSpy = testUtils.sinon.spy( loader, 'abort' );
|
|
|
|
|
|
|
@@ -478,7 +492,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
it( 'should not abort and not restart upload when image is moved', () => {
|
|
it( 'should not abort and not restart upload when image is moved', () => {
|
|
|
const file = createNativeFileMock();
|
|
const file = createNativeFileMock();
|
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
|
|
|
const abortSpy = testUtils.sinon.spy( loader, 'abort' );
|
|
const abortSpy = testUtils.sinon.spy( loader, 'abort' );
|
|
|
const loadSpy = testUtils.sinon.spy( loader, 'read' );
|
|
const loadSpy = testUtils.sinon.spy( loader, 'read' );
|
|
@@ -503,7 +517,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
evt.stop();
|
|
evt.stop();
|
|
|
}, { priority: 'high' } );
|
|
}, { priority: 'high' } );
|
|
|
|
|
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
|
|
|
model.document.once( 'change', () => {
|
|
model.document.once( 'change', () => {
|
|
|
// This is called after "manual" remove.
|
|
// This is called after "manual" remove.
|
|
@@ -539,7 +553,7 @@ describe( 'ImageUploadEditing', () => {
|
|
|
it( 'should create responsive image if server return multiple images', done => {
|
|
it( 'should create responsive image if server return multiple images', done => {
|
|
|
const file = createNativeFileMock();
|
|
const file = createNativeFileMock();
|
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
- editor.execute( 'imageUpload', { files: file } );
|
|
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
|
|
|
model.document.once( 'change', () => {
|
|
model.document.once( 'change', () => {
|
|
|
model.document.once( 'change', () => {
|
|
model.document.once( 'change', () => {
|