Explorar el Código

Added tests for utilities.

Szymon Kupś hace 8 años
padre
commit
abccac4ab8

+ 1 - 1
packages/ckeditor5-upload/src/imageuploadcommand.js

@@ -26,7 +26,7 @@ export default class ImageUploadCommand extends Command {
 	 * @param {module:engine/model/batch~Batch} [options.batch] Batch to collect all the change steps.
 	 * New batch will be created if this option is not set.
 	 */
-	_doExecute( options = {} ) {
+	_doExecute( options ) {
 		const editor = this.editor;
 		const doc = editor.document;
 		const batch = options.batch || doc.batch();

+ 31 - 0
packages/ckeditor5-upload/tests/utils.js

@@ -0,0 +1,31 @@
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+import { isImageType } from '../src/utils';
+
+describe( 'utils', () => {
+	describe( 'isImageType', () => {
+		it( 'should return true for png mime type', () => {
+			expect( isImageType( { type: 'image/png' } ) ).to.be.true;
+		} );
+
+		it( 'should return true for jpeg mime type', () => {
+			expect( isImageType( { type: 'image/jpeg' } ) ).to.be.true;
+		} );
+
+		it( 'should return true for gif mime type', () => {
+			expect( isImageType( { type: 'image/gif' } ) ).to.be.true;
+		} );
+
+		it( 'should return true for bmp mime type', () => {
+			expect( isImageType( { type: 'image/bmp' } ) ).to.be.true;
+		} );
+
+		it( 'should return false for other mime types', () => {
+			expect( isImageType( { type: 'audio/mp3' } ) ).to.be.false;
+			expect( isImageType( { type: 'video/mpeg' } ) ).to.be.false;
+		} );
+	}  );
+} );