@@ -97,7 +97,10 @@ test("reads credentials file and sends OAuth usage request", async () => {
|
||||
changed++;
|
||||
},
|
||||
async (input, init) => {
|
||||
calls.push({ url: String(input), headers: new Headers(init?.headers) });
|
||||
calls.push({
|
||||
url: input instanceof Request ? input.url : String(input),
|
||||
headers: new Headers(init?.headers),
|
||||
});
|
||||
return Response.json(payload);
|
||||
},
|
||||
60_000,
|
||||
@@ -105,10 +108,12 @@ test("reads credentials file and sends OAuth usage request", async () => {
|
||||
);
|
||||
await tracker.init();
|
||||
expect(calls).toHaveLength(1);
|
||||
expect(calls[0]!.url).toBe("https://api.anthropic.com/api/oauth/usage");
|
||||
expect(calls[0]!.headers.get("authorization")).toBe("Bearer token-123");
|
||||
expect(calls[0]!.headers.get("anthropic-beta")).toBe("oauth-2025-04-20");
|
||||
expect(calls[0]!.headers.get("accept")).toBe("application/json");
|
||||
const [call] = calls;
|
||||
if (!call) throw new Error("Missing usage request");
|
||||
expect(call.url).toBe("https://api.anthropic.com/api/oauth/usage");
|
||||
expect(call.headers.get("authorization")).toBe("Bearer token-123");
|
||||
expect(call.headers.get("anthropic-beta")).toBe("oauth-2025-04-20");
|
||||
expect(call.headers.get("accept")).toBe("application/json");
|
||||
expect(tracker.status()?.plan).toBe("max");
|
||||
expect(tracker.status()?.windows[0]?.remaining).toBe(87.5);
|
||||
expect(changed).toBe(1);
|
||||
|
||||
Reference in New Issue
Block a user