* Removes duplicate query results for a particular element. (e.g. multiple `TestElement` * instances or multiple instances of the same `ComponentHarness` class.
( results: T, )
| 468 | * instances or multiple instances of the same `ComponentHarness` class. |
| 469 | */ |
| 470 | async 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. */ |
| 494 | async function _assertResultFound<T>( |
no test coverage detected