uploadgateway.js 1.1 KB

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