mirror of
https://github.com/prdlk/jobyssey.git
synced 2026-11-02 13:12:49 +00:00
feat: add skills
This commit is contained in:
1 parent
6984212b17
commit
c50aa92862
150 files changed
+12702
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { apiFetch, USER_AGENT } from "../src/helpers";
|
||||
|
||||
// Bun's fetch injects an anonymous default User-Agent (Bun/1.3.10) when code
|
||||
// sets none. This CLI should say who is asking, in the honest style jobindex
|
||||
// already uses on htmlFetch ("Mozilla/5.0 (compatible; jobindex-cli/1.0)").
|
||||
// Assert the header is present on every request. Fails on the pre-change code.
|
||||
const originalFetch = globalThis.fetch;
|
||||
afterEach(() => {
|
||||
globalThis.fetch = originalFetch;
|
||||
});
|
||||
|
||||
describe("apiFetch user agent", () => {
|
||||
test("sends a User-Agent header", async () => {
|
||||
let init: RequestInit | undefined;
|
||||
globalThis.fetch = (async (_url: string | URL | Request, i?: RequestInit) => {
|
||||
init = i;
|
||||
return new Response("{}", { status: 200 });
|
||||
}) as unknown as typeof fetch;
|
||||
|
||||
await apiFetch("/search");
|
||||
const headers = init?.headers as Record<string, string> | Headers | undefined;
|
||||
const value =
|
||||
headers instanceof Headers ? headers.get("User-Agent") : headers?.["User-Agent"];
|
||||
expect(value).toBe(USER_AGENT);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user