Spaces:
Sleeping
Sleeping
Download apps/api/src/search/scrape.test.ts from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/search/scrape.test.ts
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/src/search/scrape.test.ts
-
curl -L -o scrape.test.ts https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/search/scrape.test.ts
1.45 kB
| jest.mock("uuid", () => ({ | |
| v7: jest.fn(() => "job-1"), | |
| })); | |
| import { scrapeSearchResults } from "./scrape"; | |
| import { getJobPriority } from "../lib/job-priority"; | |
| import { processJobInternal } from "../services/worker/scrape-worker"; | |
| jest.mock("../lib/job-priority", () => ({ | |
| getJobPriority: jest.fn().mockResolvedValue(10), | |
| })); | |
| jest.mock("../services/worker/scrape-worker", () => ({ | |
| processJobInternal: jest.fn().mockResolvedValue({ | |
| markdown: "body", | |
| metadata: { creditsUsed: 1, statusCode: 200, proxyUsed: "basic" }, | |
| }), | |
| })); | |
| describe("scrapeSearchResults", () => { | |
| it("preserves billing metadata on spawned scrape jobs", async () => { | |
| await scrapeSearchResults( | |
| [ | |
| { | |
| url: "https://example.com", | |
| title: "Example", | |
| description: "Desc", | |
| }, | |
| ], | |
| { | |
| teamId: "team-1", | |
| origin: "api", | |
| timeout: 60_000, | |
| scrapeOptions: {} as any, | |
| apiKeyId: 123, | |
| requestId: "req-1", | |
| billing: { endpoint: "agent" }, | |
| }, | |
| { debug: jest.fn(), info: jest.fn(), error: jest.fn() } as any, | |
| null as any, | |
| ); | |
| expect(getJobPriority).toHaveBeenCalledWith({ | |
| team_id: "team-1", | |
| basePriority: 10, | |
| }); | |
| expect(processJobInternal).toHaveBeenCalledWith( | |
| expect.objectContaining({ | |
| data: expect.objectContaining({ | |
| billing: { endpoint: "agent" }, | |
| }), | |
| }), | |
| ); | |
| }); | |
| }); | |