Skip to content

Commit af94f9f

Browse files
committed
refactor(flow test): traceable test cases
1 parent c476af9 commit af94f9f

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

app/domains/__test__/flows.test.ts

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ function getEnabledSteps({
6969
* - system under test should be in a certain state (step)
7070
*/
7171

72-
describe("state machine form flows", () => {
73-
[
72+
describe("flow tests", () => {
73+
const testCases = {
7474
testCasesBeratungshilfe,
7575
testCasesGeldEinklagen,
7676
testCasesFluggastrechteFormularFlugdatenNichtBefoerderung,
@@ -102,32 +102,24 @@ describe("state machine form flows", () => {
102102
testCasesFluggastrechteErfolgEU,
103103
testcasesFluggastrechteErfolgAnalog,
104104
testCasesFluggastrechteFormularProzessfuehrung,
105-
].forEach(({ machine, cases }) => {
106-
test.each([...cases])(
107-
"SUBMIT (%#) given context: %j, visits steps: %j",
108-
(context, steps) => {
109-
const actualSteps = getEnabledSteps({
110-
machine,
111-
context,
112-
transitionType: "SUBMIT",
113-
steps,
114-
});
115-
expect(actualSteps).toEqual(steps);
116-
},
117-
);
105+
} as const;
106+
const transitionTypes = ["SUBMIT", "BACK"] as const;
107+
108+
describe.each(Object.entries(testCases))("%s", (_, { machine, cases }) => {
109+
describe.each([...cases])("[%#]", (context, steps) => {
110+
test.each(transitionTypes)("%s", (transitionType) => {
111+
const expectedSteps =
112+
transitionType === "SUBMIT" ? steps : [...steps].reverse();
118113

119-
test.each([...cases])(
120-
"BACK (%#) given context: %j, visits steps: %j",
121-
(context, steps) => {
122-
const expectedSteps = [...steps].reverse();
123114
const actualSteps = getEnabledSteps({
124115
machine,
125116
context,
126-
transitionType: "BACK",
117+
transitionType,
127118
steps: expectedSteps,
128119
});
120+
129121
expect(actualSteps).toEqual(expectedSteps);
130-
},
131-
);
122+
});
123+
});
132124
});
133125
});

0 commit comments

Comments
 (0)