Skip to content

Commit 90065da

Browse files
committed
test(mfa): replace the walked-paths for-loop with it.each
1 parent f8a7c4e commit 90065da

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

tests/unit/components/MultifactorAuthentication/machine/graphTraversal/viewMatchesMachine.test.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ function describeDrivenEvents(steps: ReadonlyArray<{event: {type: string}}>): st
113113
return drivenEventLabels.length > 0 ? drivenEventLabels.join(' -> ') : 'no driven events';
114114
}
115115

116+
const walkedPathTestCases = walkedPaths.map((path) => ({
117+
title: `stays in sync with the machine along [${describeDrivenEvents(path.steps)}] to ${JSON.stringify(path.state.value)}`,
118+
path,
119+
}));
120+
116121
describe('the real MFA modal matches the machine at every step of every generated path', () => {
117122
// The navigation buffer is deliberately not reset here. The machine resets it when it enters
118123
// `closed`, which also runs when each test's fresh actor starts, so a reset here would hide a
@@ -125,13 +130,11 @@ describe('the real MFA modal matches the machine at every step of every generate
125130
jest.clearAllMocks();
126131
});
127132

128-
for (const path of walkedPaths) {
129-
it(`stays in sync with the machine along [${describeDrivenEvents(path.steps)}] to ${JSON.stringify(path.state.value)}`, async () => {
130-
renderMfaUi();
131-
await waitForBatchedUpdatesWithAct();
132-
await path.test(testConfig);
133-
});
134-
}
133+
it.each(walkedPathTestCases)('$title', async ({path}) => {
134+
renderMfaUi();
135+
await waitForBatchedUpdatesWithAct();
136+
await path.test(testConfig);
137+
});
135138
});
136139

137140
// Every settleable leaf must occur in a path that the walk above drives. `everyStateReachable.test.ts`

0 commit comments

Comments
 (0)