8
0

utils.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  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 { createImageTypeRegExp } from '../../src/imageupload/utils';
  6. describe( 'Upload utils', () => {
  7. describe( 'createImageTypeRegExp()', () => {
  8. it( 'should return RegExp for testing regular mime type', () => {
  9. expect( createImageTypeRegExp( [ 'png' ] ).test( 'image/png' ) ).to.be.true;
  10. expect( createImageTypeRegExp( [ 'png' ] ).test( 'foo/png' ) ).to.be.false;
  11. expect( createImageTypeRegExp( [ 'png' ] ).test( 'png' ) ).to.be.false;
  12. } );
  13. it( 'should return RegExp for testing mime type with dot', () => {
  14. expect( createImageTypeRegExp( [ 'vnd.microsoft.icon' ] ).test( 'image/vnd.microsoft.icon' ) ).to.be.true;
  15. expect( createImageTypeRegExp( [ 'png' ] ).test( 'foo/vnd.microsoft.icon' ) ).to.be.false;
  16. expect( createImageTypeRegExp( [ 'png' ] ).test( 'vnd.microsoft.icon' ) ).to.be.false;
  17. } );
  18. it( 'should return RegExp for testing mime type with dash', () => {
  19. expect( createImageTypeRegExp( [ 'x-xbitmap' ] ).test( 'image/x-xbitmap' ) ).to.be.true;
  20. expect( createImageTypeRegExp( [ 'png' ] ).test( 'foo/x-xbitmap' ) ).to.be.false;
  21. expect( createImageTypeRegExp( [ 'png' ] ).test( 'x-xbitmap' ) ).to.be.false;
  22. } );
  23. it( 'should return RegExp for testing mime type with plus', () => {
  24. expect( createImageTypeRegExp( [ 'svg+xml' ] ).test( 'image/svg+xml' ) ).to.be.true;
  25. expect( createImageTypeRegExp( [ 'png' ] ).test( 'foo/svg+xml' ) ).to.be.false;
  26. expect( createImageTypeRegExp( [ 'png' ] ).test( 'svg+xml' ) ).to.be.false;
  27. } );
  28. } );
  29. } );