uploadgateway.js 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import FileUploader from '../../src/uploadgateway/fileuploader';
  6. import UploadGateway from '../../src/uploadgateway/uploadgateway';
  7. import Token from '../../src/token/token';
  8. import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
  9. describe( 'UploadGateway', () => {
  10. const token = new Token( 'url', { initValue: 'token', autoRefresh: false } );
  11. describe( 'constructor()', () => {
  12. it( 'should throw error when no token provided', () => {
  13. expectToThrowCKEditorError( () => new UploadGateway( undefined, 'test' ), 'uploadgateway-missing-token' );
  14. } );
  15. it( 'should throw error when no apiAddress provided', () => {
  16. expectToThrowCKEditorError( () => new UploadGateway( token ), 'uploadgateway-missing-api-address' );
  17. } );
  18. } );
  19. describe( 'upload()', () => {
  20. it( 'should return `FileUploader` instance', () => {
  21. const uploader = new UploadGateway( token, 'test' );
  22. expect( uploader.upload( 'file' ) ).to.be.instanceOf( FileUploader );
  23. } );
  24. } );
  25. } );