Skip to content

Commit 54efd57

Browse files
committed
test(app): deduplicate open parser assertion block
1 parent 9035463 commit 54efd57

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

packages/app/tests/docker-git/parser.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ const expectProjectDirRunUpCommand = (
5353
expect(command.runUp).toBe(expectedRunUp)
5454
})
5555

56+
const expectAttachProjectDirCommand = (
57+
args: ReadonlyArray<string>,
58+
expectedProjectDir: string
59+
) =>
60+
Effect.sync(() => {
61+
const command = parseOrThrow(args)
62+
if (command._tag !== "Attach") {
63+
throw new Error("expected Attach command")
64+
}
65+
expect(command.projectDir).toBe(expectedProjectDir)
66+
})
67+
5668
const expectCreateCommand = (
5769
args: ReadonlyArray<string>,
5870
onRight: (command: CreateCommand) => void
@@ -209,22 +221,10 @@ describe("parseArgs", () => {
209221
}))
210222

211223
it.effect("parses attach with GitHub issue url into issue workspace", () =>
212-
Effect.sync(() => {
213-
const command = parseOrThrow(["attach", "https://github.com/org/repo/issues/7"])
214-
if (command._tag !== "Attach") {
215-
throw new Error("expected Attach command")
216-
}
217-
expect(command.projectDir).toBe(".docker-git/org/repo/issue-7")
218-
}))
224+
expectAttachProjectDirCommand(["attach", "https://github.com/org/repo/issues/7"], ".docker-git/org/repo/issue-7"))
219225

220226
it.effect("parses open with GitHub issue url into issue workspace", () =>
221-
Effect.sync(() => {
222-
const command = parseOrThrow(["open", "https://github.com/org/repo/issues/7"])
223-
if (command._tag !== "Attach") {
224-
throw new Error("expected Attach command")
225-
}
226-
expect(command.projectDir).toBe(".docker-git/org/repo/issue-7")
227-
}))
227+
expectAttachProjectDirCommand(["open", "https://github.com/org/repo/issues/7"], ".docker-git/org/repo/issue-7"))
228228

229229
it.effect("parses mcp-playwright command in current directory", () =>
230230
expectProjectDirRunUpCommand(["mcp-playwright"], "McpPlaywrightUp", ".", true))

0 commit comments

Comments
 (0)