Spaces:
Sleeping
Sleeping
Download apps/api/src/services/monitoring/runner.test.ts from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/services/monitoring/runner.test.ts
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/src/services/monitoring/runner.test.ts
-
curl -L -o runner.test.ts https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/services/monitoring/runner.test.ts
1.5 kB
| jest.mock("uuid", () => ({ | |
| v7: () => "test-uuid-v7", | |
| })); | |
| import { isMonitorCheckStale, MONITOR_CHECK_STALE_TIMEOUT_MS } from "./runner"; | |
| describe("monitoring runner", () => { | |
| describe("isMonitorCheckStale", () => { | |
| const now = new Date("2026-05-06T12:00:00.000Z"); | |
| it("returns true when a running check is at least 1 hour old", () => { | |
| expect( | |
| isMonitorCheckStale( | |
| { | |
| started_at: new Date( | |
| now.getTime() - MONITOR_CHECK_STALE_TIMEOUT_MS, | |
| ).toISOString(), | |
| updated_at: now.toISOString(), | |
| created_at: now.toISOString(), | |
| }, | |
| now, | |
| ), | |
| ).toBe(true); | |
| }); | |
| it("returns false when a running check is not yet stale", () => { | |
| expect( | |
| isMonitorCheckStale( | |
| { | |
| started_at: new Date( | |
| now.getTime() - MONITOR_CHECK_STALE_TIMEOUT_MS + 1, | |
| ).toISOString(), | |
| updated_at: now.toISOString(), | |
| created_at: now.toISOString(), | |
| }, | |
| now, | |
| ), | |
| ).toBe(false); | |
| }); | |
| it("falls back to updated_at for malformed started_at values", () => { | |
| expect( | |
| isMonitorCheckStale( | |
| { | |
| started_at: null, | |
| updated_at: new Date( | |
| now.getTime() - MONITOR_CHECK_STALE_TIMEOUT_MS, | |
| ).toISOString(), | |
| created_at: now.toISOString(), | |
| }, | |
| now, | |
| ), | |
| ).toBe(true); | |
| }); | |
| }); | |
| }); | |