uploadgateway.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * @license Copyright (c) 2003-2017, 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. describe( 'UploadGateway', () => {
  10. const token = new Token( 'url', { initTokenValue: 'token', autoRefresh: false } );
  11. describe( 'constructor()', () => {
  12. it( 'should throw error when no token provided', () => {
  13. expect( () => new UploadGateway( undefined, 'test' ) ).to.throw( 'Token must be provided' );
  14. } );
  15. it( 'should throw error when no apiAddress provided', () => {
  16. expect( () => new UploadGateway( token ) ).to.throw( 'Api address must be provided' );
  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. } );