MCPcopy Create free account
hub / github.com/angular/components / _removeDuplicateQueryResults

Function _removeDuplicateQueryResults

src/cdk/testing/harness-environment.ts:470–491  ·  view source on GitHub ↗

* Removes duplicate query results for a particular element. (e.g. multiple `TestElement` * instances or multiple instances of the same `ComponentHarness` class.

(
  results: T,
)

Source from the content-addressed store, hash-verified

468 * instances or multiple instances of the same `ComponentHarness` class.
469 */
470async function _removeDuplicateQueryResults<T extends (ComponentHarness | TestElement | null)[]>(
471 results: T,
472): Promise<T> {
473 let testElementMatched = false;
474 let matchedHarnessTypes = new Set();
475 const dedupedMatches = [];
476 for (const result of results) {
477 if (!result) {
478 continue;
479 }
480 if (result instanceof ComponentHarness) {
481 if (!matchedHarnessTypes.has(result.constructor)) {
482 matchedHarnessTypes.add(result.constructor);
483 dedupedMatches.push(result);
484 }
485 } else if (!testElementMatched) {
486 testElementMatched = true;
487 dedupedMatches.push(result);
488 }
489 }
490 return dedupedMatches as T;
491}
492
493/** Verifies that there is at least one result in an array. */
494async function _assertResultFound<T>(

Callers 1

Calls 2

pushMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected