/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/console/app/test/rateLimiter.test.ts
19 строк
650 B
Frank
zen: rate limiter
15 апр 2026, 03:29
15 апр 2026, 03:29
8df7ccc
Код
Авторство
О чём код?
import { describe, expect, test } from "bun:test" import { getRetryAfterDay } from "../src/routes/zen/util/ipRateLimiter" describe("getRetryAfterDay", () => { test("returns full day at midnight UTC", () => { const midnight = Date.UTC(2026, 0, 15, 0, 0, 0, 0) expect(getRetryAfterDay(midnight)).toBe(86_400) }) test("returns remaining seconds until next UTC day", () => { const noon = Date.UTC(2026, 0, 15, 12, 0, 0, 0) expect(getRetryAfterDay(noon)).toBe(43_200) }) test("rounds up to nearest second", () => { const almost = Date.UTC(2026, 0, 15, 23, 59, 59, 500) expect(getRetryAfterDay(almost)).toBe(1) }) })