Skip to content

Commit 0b4c474

Browse files
committed
Inline navigate step handling
1 parent e5d42b1 commit 0b4c474

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

src/index.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export class Extension extends StringifyExtension {
4343
}
4444

4545
async stringifyStep(out: LineWriter, step: Step, flow: UserFlow) {
46-
// Events
4746
switch (step.type) {
4847
case "click":
4948
out.appendLine(
@@ -56,30 +55,26 @@ export class Extension extends StringifyExtension {
5655
)
5756
break
5857
case "navigate":
58+
if (step === flow.steps.find((step) => step.type === "navigate")) {
59+
for (const { url, title } of step.assertedEvents ?? []) {
60+
if (url) {
61+
out.appendLine(`expect(location.href).toBe("${url}")`)
62+
}
63+
if (title) {
64+
out.appendLine(`expect(document.title).toBe("${title}")`)
65+
}
66+
}
67+
} else {
68+
console.log(
69+
"Warning: Testing Library does not currently handle more than one navigation step per test.",
70+
)
71+
}
5972
break
6073
default:
6174
console.log(
6275
`Warning: Testing Library does not currently handle migrating steps of type: ${step.type}. Please check the output to see how this might affect your test.`,
6376
)
6477
}
65-
66-
// Assertions
67-
if (step.type === "navigate") {
68-
if (step === flow.steps.find((step) => step.type === "navigate")) {
69-
for (const { url, title } of step.assertedEvents ?? []) {
70-
if (url) {
71-
out.appendLine(`expect(location.href).toBe("${url}")`)
72-
}
73-
if (title) {
74-
out.appendLine(`expect(document.title).toBe("${title}")`)
75-
}
76-
}
77-
} else {
78-
console.log(
79-
"Warning: Testing Library does not currently handle more than one navigation step per test.",
80-
)
81-
}
82-
}
8378
}
8479
}
8580

0 commit comments

Comments
 (0)