Browse Source

Added tests for the utils.

Maciej Bukowski 5 years ago
parent
commit
b9b0ffd6a1

+ 4 - 3
packages/ckeditor5-watchdog/src/contextwatchdog.js

@@ -14,6 +14,9 @@ import EditorWatchdog from './editorwatchdog';
 import areConnectedThroughProperties from './utils/areconnectedthroughproperties';
 import getSubNodes from './utils/getsubnodes';
 
+/**
+ * The Context Watchdog class.
+ */
 export default class ContextWatchdog extends Watchdog {
 	/**
 	 * @param {module:watchdog/watchdog~WatchdogConfig} [config] The watchdog plugin configuration.
@@ -336,9 +339,7 @@ class ActionQueue {
 			}
 		}
 
-		if ( this._queuedActions.length === 0 ) {
-			this._onEmptyCallbacks.forEach( cb => cb() );
-		}
+		this._onEmptyCallbacks.forEach( cb => cb() );
 	}
 
 	/**

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

@@ -211,4 +211,22 @@ describe( 'areConnectedThroughProperties()', () => {
 
 		expect( areConnectedThroughProperties( el1, el2 ) ).to.be.false;
 	} );
+
+	it( 'should skip excluded properties', () => {
+		const shared = { foo: [] };
+		const el1 = { shared };
+		const el2 = { shared };
+
+		expect( areConnectedThroughProperties( el1, el2, new Set( [ shared ] ) ) ).to.be.false;
+	} );
+
+	it( 'should skip excluded properties #2', () => {
+		const shared = {};
+		const sharedNotExcluded = {};
+
+		const el1 = { shared, sharedNotExcluded };
+		const el2 = { shared, sharedNotExcluded };
+
+		expect( areConnectedThroughProperties( el1, el2, new Set( [ shared ] ) ) ).to.be.true;
+	} );
 } );