8
0
Просмотр исходного кода

Internal: Brought back a test removed in [ab63b60](https://github.com/ckeditor/ckeditor5-watchdog/commit/ab63b603094a303f482a9520a8601264f993ca7f) that caused CC drop (see [ckeditor/ckeditor5#5848](https://github.com/ckeditor/ckeditor5/issues/5848)).

Marek Lewandowski 6 лет назад
Родитель
Сommit
4ee53f595a
1 измененных файлов с 32 добавлено и 0 удалено
  1. 32 0
      packages/ckeditor5-watchdog/tests/watchdog.js

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

@@ -479,6 +479,38 @@ describe( 'Watchdog', () => {
 			} );
 		} );
 
+		it( 'Watchdog should warn if the CKEditorError missing its context', () => {
+			const watchdog = new Watchdog();
+
+			watchdog.setCreator( ( el, config ) => ClassicTestEditor.create( el, config ) );
+			watchdog.setDestructor( editor => editor.destroy() );
+
+			// sinon.stub( window, 'onerror' ).value( undefined ); and similar do not work.
+			const originalErrorHandler = window.onerror;
+			window.onerror = undefined;
+
+			sinon.stub( console, 'warn' );
+
+			return watchdog.create( element ).then( () => {
+				setTimeout( () => throwCKEditorError( 'foo' ) );
+
+				return new Promise( res => {
+					setTimeout( () => {
+						window.onerror = originalErrorHandler;
+
+						expect( watchdog.crashes ).to.deep.equal( [] );
+
+						sinon.assert.calledWithExactly(
+							console.warn,
+							'The error is missing its context and Watchdog cannot restart the proper editor.'
+						);
+
+						watchdog.destroy().then( res );
+					} );
+				} );
+			} );
+		} );
+
 		it( 'Watchdog should omit error if the CKEditorError context is equal to null', () => {
 			const watchdog = new Watchdog();