Parcourir la source

Aligned testing CKEditor errors.

Maciej Bukowski il y a 6 ans
Parent
commit
80d7219405

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

@@ -21,7 +21,7 @@ import areConnectedThroughProperties from '@ckeditor/ckeditor5-utils/src/areconn
  * It keeps an {@link module:core/editor/editor~Editor editor} instance running.
  * If a {@link module:utils/ckeditorerror~CKEditorError `CKEditorError` error}
  * is thrown by the editor, it tries to restart the editor to the state before the crash. All other errors
- * are transparent to the watchdog.
+ * are transparent to the watchdog. By looking at the error context, the Watchdog restarts only the editor which crashed.
  *
  * Note that the watchdog does not handle errors during editor initialization (`Editor.create()`)
  * and editor destruction (`editor.destroy()`). Errors at these stages mean that there is a serious

+ 11 - 2
packages/ckeditor5-watchdog/tests/watchdog.js

@@ -9,6 +9,7 @@ import Watchdog from '../src/watchdog';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
+import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 describe( 'Watchdog', () => {
 	let sourceElement;
@@ -50,14 +51,22 @@ describe( 'Watchdog', () => {
 			const watchdog = new Watchdog();
 			watchdog.setDestructor( editor => editor.destroy() );
 
-			expect( () => watchdog.create() ).to.throw( CKEditorError, /^watchdog-creator-not-defined/ );
+			expectToThrowCKEditorError(
+				() => watchdog.create(),
+				/^watchdog-creator-not-defined/,
+				null
+			);
 		} );
 
 		it( 'should throw an error when the destructor is not defined', () => {
 			const watchdog = new Watchdog();
 			watchdog.setCreator( ( el, config ) => ClassicTestEditor.create( el, config ) );
 
-			expect( () => watchdog.create() ).to.throw( CKEditorError, /^watchdog-destructor-not-defined/ );
+			expectToThrowCKEditorError(
+				() => watchdog.create(),
+				/^watchdog-destructor-not-defined/,
+				null
+			);
 		} );
 	} );