Skip to content

Commit

Permalink
refactor: test utils to simplify assertThemedProps
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonailea committed Apr 1, 2024
1 parent e777ea3 commit 6b78dfb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/calcite-components/src/tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export async function assertThemedProps(
target: E2EElement,
props: [string, string, string | Record<string, { attribute: string; value: string }> | undefined][],
): Promise<void> {
const styles = await target.getComputedStyle();
let styles = await target.getComputedStyle();
for (const [targetProp, themedTokenValue, state] of props) {
if (state) {
if (typeof state === "string") {
Expand Down Expand Up @@ -515,13 +515,13 @@ export async function assertThemedProps(
await page.waitForChanges();
}

const statefulStyles = await target.getComputedStyle();
expect(statefulStyles[targetProp]).toBe(themedTokenValue);
} else {
expect(styles[targetProp]).toBe(themedTokenValue);
styles = await target.getComputedStyle();
// reset the mouse state to ensure each "state" starts with a clean slate
page.mouse.reset();
}
// reset the mouse state to ensure each "state" starts with a clean slate
page.mouse.reset();

await page.waitForChanges();
expect(Object.is(styles[targetProp], themedTokenValue)).toBe(true);
}
}

Expand Down

0 comments on commit 6b78dfb

Please sign in to comment.