Skip to content

Commit bddca23

Browse files
committed
test(app): deduplicate open parser assertion block
1 parent 8315953 commit bddca23

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

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
@@ -196,22 +208,10 @@ describe("parseArgs", () => {
196208
}))
197209

198210
it.effect("parses attach with GitHub issue url into issue workspace", () =>
199-
Effect.sync(() => {
200-
const command = parseOrThrow(["attach", "https://github.com/org/repo/issues/7"])
201-
if (command._tag !== "Attach") {
202-
throw new Error("expected Attach command")
203-
}
204-
expect(command.projectDir).toBe(".docker-git/org/repo/issue-7")
205-
}))
211+
expectAttachProjectDirCommand(["attach", "https://github.com/org/repo/issues/7"], ".docker-git/org/repo/issue-7"))
206212

207213
it.effect("parses open with GitHub issue url into issue workspace", () =>
208-
Effect.sync(() => {
209-
const command = parseOrThrow(["open", "https://github.com/org/repo/issues/7"])
210-
if (command._tag !== "Attach") {
211-
throw new Error("expected Attach command")
212-
}
213-
expect(command.projectDir).toBe(".docker-git/org/repo/issue-7")
214-
}))
214+
expectAttachProjectDirCommand(["open", "https://github.com/org/repo/issues/7"], ".docker-git/org/repo/issue-7"))
215215

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

0 commit comments

Comments
 (0)