Explorar el Código

Added simple test.

Maciej Bukowski hace 6 años
padre
commit
92046387bd
Se han modificado 1 ficheros con 46 adiciones y 0 borrados
  1. 46 0
      packages/ckeditor5-watchdog/tests/watchdog.js

+ 46 - 0
packages/ckeditor5-watchdog/tests/watchdog.js

@@ -0,0 +1,46 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import Watchdog from '../src/watchdog';
+import { watch } from 'chokidar';
+
+describe( 'Watchdog', () => {
+	describe( 'simple scenarios', () => {
+		it( '#1', () => {
+			const watchdog = new Watchdog();
+
+			const editorCreateSpy = sinon.spy( FakeEditor, 'create' );
+			const editorDestroySpy = sinon.spy( FakeEditor.prototype, 'destroy' );
+
+			class FakeEditor {
+				static create( el, config ) {
+					this.el = el;
+					this.config = config;
+
+					return Promise.resolve();
+				}
+
+				destroy() {
+					return Promise.resolve();
+				}
+			}
+
+			watchdog.setCreator( ( el, config ) => FakeEditor.create( el, config ) );
+			watchdog.setDestructor( editor => editor.destroy() );
+
+			return watchdog.create()
+				.then( () => {
+					sinon.assert.calledOnce( editorCreateSpy );
+					sinon.assert.notCalled( editorDestroySpy );
+
+					return watchdog.destroy();
+				} )
+				.then( () => {
+					sinon.assert.calledOnce( editorCreateSpy );
+					sinon.assert.calledOnce( editorDestroySpy );
+				} )
+		} );
+	} );
+} );