Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.8 kB ยท 67 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768import { describe, expect, test } from "vitest";
import { isInBlacklist } from "./blacklist";import { endOfDay, isSameDay, startOfDay } from "./utils";
describe("startOfDay", () => { test("truncates to UTC midnight", () => { expect(startOfDay(new Date("2024-03-10T17:45:12.345Z")).toISOString()).toBe( "2024-03-10T00:00:00.000Z", ); });
test("does not mutate its input", () => { const input = new Date("2024-03-10T17:45:12.345Z"); startOfDay(input); expect(input.toISOString()).toBe("2024-03-10T17:45:12.345Z"); });});
describe("endOfDay", () => { test("extends to the last UTC millisecond", () => { expect(endOfDay(new Date("2024-03-10T00:00:00.000Z")).toISOString()).toBe( "2024-03-10T23:59:59.999Z", ); });
test("handles a leap day", () => { expect(endOfDay(new Date("2024-02-29T12:00:00Z")).toISOString()).toBe( "2024-02-29T23:59:59.999Z", ); });});
describe("isSameDay", () => { test("matches the first and last millisecond of a UTC day", () => { expect( isSameDay( new Date("2024-03-10T00:00:00.000Z"), new Date("2024-03-10T23:59:59.999Z"), ), ).toBe(true); });
test("splits across UTC midnight", () => { expect( isSameDay( new Date("2024-03-10T23:59:59.999Z"), new Date("2024-03-11T00:00:00.000Z"), ), ).toBe(false); });
test("compares in UTC regardless of the input offset", () => { expect( isSameDay( new Date("2024-03-10T20:00:00-05:00"), new Date("2024-03-11T23:30:00Z"), ), ).toBe(true); });});
describe("isInBlacklist", () => { test("returns undefined for a normal day", () => { expect(isInBlacklist(new Date("2024-01-01T12:00:00Z"))).toBeUndefined(); });});