|
|
@@ -8,11 +8,14 @@
|
|
|
import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
|
|
|
import CloudServicesUploadAdapter from '../src/cloudservicesuploadadapter';
|
|
|
import FileRepository from '@ckeditor/ckeditor5-upload/src/filerepository';
|
|
|
+
|
|
|
import UploadGatewayMock from './_utils/uploadgatewaymock';
|
|
|
import { createNativeFileMock } from '@ckeditor/ckeditor5-upload/tests/_utils/mocks';
|
|
|
+import CloudServicesMock from '@ckeditor/ckeditor5-cloudservices/tests/_utils/cloudservicesmock';
|
|
|
|
|
|
// Store original uploader.
|
|
|
const CSUploader = CloudServicesUploadAdapter._UploadGateway;
|
|
|
+const CloudServices = CloudServicesUploadAdapter._CloudServices;
|
|
|
|
|
|
describe( 'CloudServicesUploadAdapter', () => {
|
|
|
let div;
|
|
|
@@ -20,11 +23,13 @@ describe( 'CloudServicesUploadAdapter', () => {
|
|
|
before( () => {
|
|
|
// Mock uploader.
|
|
|
CloudServicesUploadAdapter._UploadGateway = UploadGatewayMock;
|
|
|
+ CloudServicesUploadAdapter._CloudServices = CloudServicesMock;
|
|
|
} );
|
|
|
|
|
|
after( () => {
|
|
|
// Restore original uploader.
|
|
|
CloudServicesUploadAdapter._UploadGateway = CSUploader;
|
|
|
+ CloudServicesUploadAdapter._CloudServices = CloudServices;
|
|
|
} );
|
|
|
|
|
|
beforeEach( () => {
|
|
|
@@ -44,48 +49,31 @@ describe( 'CloudServicesUploadAdapter', () => {
|
|
|
.create( div, {
|
|
|
plugins: [ CloudServicesUploadAdapter ],
|
|
|
cloudServices: {
|
|
|
- token: 'abc',
|
|
|
+ tokenUrl: 'abc',
|
|
|
uploadUrl: 'http://upload.mock.url/'
|
|
|
}
|
|
|
} )
|
|
|
.then( editor => {
|
|
|
- expect( UploadGatewayMock.lastToken ).to.equal( 'abc' );
|
|
|
+ expect( UploadGatewayMock.lastToken.value ).to.equal( 'token' );
|
|
|
expect( UploadGatewayMock.lastUploadUrl ).to.equal( 'http://upload.mock.url/' );
|
|
|
|
|
|
return editor.destroy();
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
- it( 'should not set loader if there is no token', () => {
|
|
|
- UploadGatewayMock.lastToken = undefined;
|
|
|
-
|
|
|
- return ClassicTestEditor
|
|
|
- .create( div, {
|
|
|
- plugins: [ CloudServicesUploadAdapter ]
|
|
|
- } )
|
|
|
- .then( editor => {
|
|
|
- expect( UploadGatewayMock.lastToken ).to.be.an( 'undefined' );
|
|
|
-
|
|
|
- return editor.destroy();
|
|
|
- } );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should set the default config.cloudServices.uploadUrl', () => {
|
|
|
+ it( 'should set the default uploadUrl', () => {
|
|
|
const expectedDefaultUrl = 'https://files.cke-cs.com/upload/';
|
|
|
|
|
|
return ClassicTestEditor
|
|
|
.create( div, {
|
|
|
plugins: [ CloudServicesUploadAdapter ],
|
|
|
cloudServices: {
|
|
|
- token: 'abc'
|
|
|
+ tokenUrl: 'abc'
|
|
|
}
|
|
|
} )
|
|
|
.then( editor => {
|
|
|
- expect( UploadGatewayMock.lastToken ).to.equal( 'abc' );
|
|
|
expect( UploadGatewayMock.lastUploadUrl ).to.equal( expectedDefaultUrl );
|
|
|
|
|
|
- expect( editor.config.get( 'cloudServices.uploadUrl' ) ).to.equal( expectedDefaultUrl );
|
|
|
-
|
|
|
return editor.destroy();
|
|
|
} );
|
|
|
} );
|
|
|
@@ -98,7 +86,7 @@ describe( 'CloudServicesUploadAdapter', () => {
|
|
|
return ClassicTestEditor.create( div, {
|
|
|
plugins: [ CloudServicesUploadAdapter ],
|
|
|
cloudServices: {
|
|
|
- token: 'abc',
|
|
|
+ tokenUrl: 'abc',
|
|
|
uploadUrl: 'http://upload.mock.url/'
|
|
|
}
|
|
|
} ).then( _editor => {
|