8
0
Maciej Bukowski 5 лет назад
Родитель
Сommit
7e4e046cce

+ 9 - 0
packages/ckeditor5-watchdog/tests/areconnectedtroughproperties.js

@@ -229,4 +229,13 @@ describe( 'areConnectedThroughProperties()', () => {
 
 		expect( areConnectedThroughProperties( el1, el2, new Set( [ shared ] ) ) ).to.be.true;
 	} );
+
+	it( 'should skip the `nested` key since we share props withing ', () => {
+		const shared = {};
+
+		const el1 = { nested: shared };
+		const el2 = { nested: shared };
+
+		expect( areConnectedThroughProperties( el1, el2 ) ).to.be.false;
+	} );
 } );

+ 28 - 1
packages/ckeditor5-watchdog/tests/contextwatchdog.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-/* globals document, setTimeout, window */
+/* globals document, setTimeout, window, console */
 
 import ContextWatchdog from '../src/contextwatchdog';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
@@ -120,6 +120,33 @@ describe( 'ContextWatchdog', () => {
 			sinon.assert.calledOnce( customDestructor );
 		} );
 
+		it( 'should log if an error happens during the component destructing', async () => {
+			const mainWatchdog = new ContextWatchdog();
+
+			const consoleErrorStub = sinon.stub( console, 'error' );
+			const err = new Error( 'foo' );
+			mainWatchdog.setCreator( config => Context.create( config ) );
+			mainWatchdog.setDestructor( async editor => {
+				await editor.destroy();
+
+				throw err;
+			} );
+
+			await mainWatchdog.create();
+
+			await mainWatchdog._restart();
+
+			sinon.assert.calledWith(
+				consoleErrorStub,
+				'An error happened during destructing.',
+				err
+			);
+
+			mainWatchdog.setDestructor( editor => editor.destroy() );
+
+			await mainWatchdog.destroy();
+		} );
+
 		describe( 'in case of error handling', () => {
 			it( 'should restart the `Context`', async () => {
 				mainWatchdog = ContextWatchdog.for( Context, {} );