Przeglądaj źródła

Added mock for CloudServices to prevent duplications.

Maciej Bukowski 8 lat temu
rodzic
commit
fd818341f8

+ 1 - 1
packages/ckeditor5-cloud-services/src/cloudservices.js

@@ -8,7 +8,7 @@
  */
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
-import Token from '@ckeditor/ckeditor-cloudservices-core/src/token/token';
+import Token from 'ckeditor-cloudservices-core/src/token/token';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
 /**

+ 26 - 0
packages/ckeditor5-cloud-services/tests/_utils/cloudservicesmock.js

@@ -0,0 +1,26 @@
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+
+/**
+ * Mocked CloudServices that
+ */
+export default class CloudServicesMock extends Plugin {
+	init() {
+		const editor = this.editor;
+		const config = editor.config;
+
+		const options = config.get( 'cloudServices' );
+
+		for ( const optionName in options ) {
+			this[ optionName ] = options[ optionName ];
+		}
+
+		this.token = {
+			value: 'token'
+		};
+	}
+}

+ 3 - 2
packages/ckeditor5-cloud-services/tests/cloudservices.js

@@ -10,8 +10,9 @@ import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictest
 import TokenMock from './_utils/tokenmock';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
+const Token = CloudServices.Token;
+
 describe( 'CloudServices', () => {
-	const OriginalToken = CloudServices.Token;
 	let element;
 
 	beforeEach( () => {
@@ -21,7 +22,7 @@ describe( 'CloudServices', () => {
 	} );
 
 	afterEach( () => {
-		CloudServices.Token = OriginalToken;
+		CloudServices.Token = Token;
 		document.body.removeChild( element );
 	} );