Przeglądaj źródła

Updated tests and docs to the `destroyed` state.

Maciej Bukowski 6 lat temu
rodzic
commit
b6ef4ef18e

+ 7 - 1
packages/ckeditor5-watchdog/src/watchdog.js

@@ -238,7 +238,8 @@ export default class Watchdog {
 	}
 
 	/**
-	 * Destroys the current editor instance by using the destructor passed to the {@link #setDestructor `setDestructor()`} method.
+	 * Destroys the current editor instance by using the destructor passed to the {@link #setDestructor `setDestructor()`} method
+	 * and set state to `destroyed`.
 	 *
 	 * @returns {Promise}
 	 */
@@ -248,6 +249,11 @@ export default class Watchdog {
 		} );
 	}
 
+	/**
+	 * Destroys the current editor instance by using the destructor passed to the {@link #setDestructor `setDestructor()`} method.
+	 *
+	 * @private
+	 */
 	_destroy() {
 		window.removeEventListener( 'error', this._boundErrorHandler );
 		this.stopListening( this._editor.model.document, 'change:data', this._throttledSave );

+ 24 - 17
packages/ckeditor5-watchdog/tests/watchdog.js

@@ -776,7 +776,11 @@ describe( 'Watchdog', () => {
 
 							expect( watchdog.state ).to.equal( 'ready' );
 
-							watchdog.destroy().then( res );
+							watchdog.destroy().then( () => {
+								expect( watchdog.state ).to.equal( 'destroyed' );
+
+								res();
+							} );
 						} );
 					} );
 				} );
@@ -806,22 +810,25 @@ describe( 'Watchdog', () => {
 						setTimeout( () => {
 							window.onerror = originalErrorHandler;
 
-							expect( states ).to.deep.equal( [
-								'ready',
-								'crashed',
-								'initializing',
-								'ready',
-								'crashed',
-								'initializing',
-								'ready',
-								'crashed',
-								'initializing',
-								'ready',
-								'crashed',
-								'crashedPermanently'
-							] );
-
-							watchdog.destroy().then( res );
+							watchdog.destroy().then( () => {
+								expect( states ).to.deep.equal( [
+									'ready',
+									'crashed',
+									'initializing',
+									'ready',
+									'crashed',
+									'initializing',
+									'ready',
+									'crashed',
+									'initializing',
+									'ready',
+									'crashed',
+									'crashedPermanently',
+									'destroyed'
+								] );
+
+								res();
+							} );
 						} );
 					} );
 				} );