mirror of
https://github.com/prdlk/jobyssey.git
synced 2026-11-08 16:07:38 +00:00
24 lines
1.3 KiB
TypeScript
Executable File
24 lines
1.3 KiB
TypeScript
Executable File
import { describe, expect, test } from "bun:test"
|
|
import { runCLI, parseJSON } from "./helpers"
|
|
|
|
describe("wellfound-cli", () => {
|
|
test("search returns real results for a common role", async () => {
|
|
const res = await runCLI(["search", "-q", "senior software engineer", "--location", "new-york", "--limit", "5", "--no-description"])
|
|
expect(res.exitCode).toBe(0)
|
|
const json = parseJSON<{ meta: { count: number }; results: { id: string; title: string; company: string | null; location: string | null; date: string | null; url: string }[] }>(res)
|
|
expect(json.results.length).toBeGreaterThan(0)
|
|
for (const r of json.results) {
|
|
expect(r.id).toBeTruthy(); expect(r.title).toBeTruthy(); expect(r.url).toContain("wellfound.com/jobs/")
|
|
expect(r).toHaveProperty("company"); expect(r).toHaveProperty("location"); expect(r).toHaveProperty("date")
|
|
}
|
|
})
|
|
test("bogus flag exits 1 with JSON error on stderr", async () => {
|
|
const res = await runCLI(["search", "-q", "x", "--bogus"])
|
|
expect(res.exitCode).toBe(1); expect(JSON.parse(res.stderr)).toHaveProperty("error")
|
|
})
|
|
test("missing query exits 1 with JSON error", async () => {
|
|
const res = await runCLI(["search"])
|
|
expect(res.exitCode).toBe(1); expect(JSON.parse(res.stderr).code).toBe("NO_QUERY")
|
|
})
|
|
})
|