Skip to content

Commit

Permalink
test: fix checkOutlet utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
platosha committed Sep 27, 2024
1 parent 746fc8d commit 2f45e8f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/router/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ export const onAfterEnterAction = createWebComponentAction('onAfterEnter');
export const onAfterLeaveAction = createWebComponentAction('onAfterLeave');

export function checkOutletContents<T extends Element>(
root: T,
root: T | undefined,
valueGetter: keyof T,
expectedValues: readonly string[],
): void {
let currentElementToCheck = root;
for (const expectedValue of expectedValues) {
expect(currentElementToCheck, `Failed to find a child '${expectedValue}'`).to.exist;
expect(currentElementToCheck[valueGetter]).to.match(new RegExp(expectedValue, 'ui'));
expect(currentElementToCheck![valueGetter]).to.match(new RegExp(expectedValue, 'ui'));
expect(
currentElementToCheck.children.length,
currentElementToCheck!.children.length,
`Expect each outlet element to have no more than 1 child`,
).to.be.below(2);
currentElementToCheck = currentElementToCheck.children[0] as T;
currentElementToCheck = currentElementToCheck!.children[0] as T | undefined;
}
expect(
currentElementToCheck,
`Got '${String(expectedValues)}' values to check but got at least one more child in outlet: '${String(
currentElementToCheck[valueGetter],
currentElementToCheck ? currentElementToCheck[valueGetter] : undefined,
)}'`,
).to.be.an('undefined');
}

0 comments on commit 2f45e8f

Please sign in to comment.