Skip to content
Source
Sign inSign up
fuko/trytanstackdb-v2
Open History to see the last commit

latency.test.ts

22 lines716 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { LATENCY_PRESETS, formatDuration, formatLatency } from "./latency";
4​
5describe("formatLatency", () => {
6 it("formats every preset", () => {
7 expect(LATENCY_PRESETS.map(formatLatency)).toEqual(["0 ms", "500 ms", "2 s", "5 s"]);
8 });
9​
10 it("keeps fractional seconds", () => {
11 expect(formatLatency(1500)).toBe("1.5 s");
12 });
13});
14​
15describe("formatDuration", () => {
16 it("shows milliseconds under a second, then seconds with one decimal", () => {
17 expect(formatDuration(0)).toBe("0 ms");
18 expect(formatDuration(502.4)).toBe("502 ms");
19 expect(formatDuration(2013)).toBe("2.0 s");
20 expect(formatDuration(5049)).toBe("5.0 s");
21 });
22});