Vitest med enhetstester utan databas och databastester mot en egen testdatabas vars namn måste sluta på _test. Rättar tomma MAP_*-värden i .env och säkerhetskopior med å, ä och ö i filnamnet. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
23 lines
813 B
TypeScript
23 lines
813 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatBytes, formatDuration } from "@/lib/format";
|
|
|
|
describe("formatBytes", () => {
|
|
it("visar storlekar med svenskt decimaltecken", () => {
|
|
expect(formatBytes(0)).toBe("0 B");
|
|
expect(formatBytes(1023)).toBe("1023 B");
|
|
expect(formatBytes(1536)).toBe("1,5 KB");
|
|
expect(formatBytes(1024 * 1024)).toBe("1,0 MB");
|
|
expect(formatBytes(150 * 1024 * 1024)).toBe("150 MB");
|
|
expect(formatBytes(3 * 1024 ** 3)).toBe("3,0 GB");
|
|
});
|
|
});
|
|
|
|
describe("formatDuration", () => {
|
|
it("visar dagar, timmar och minuter", () => {
|
|
expect(formatDuration(59)).toBe("0 min");
|
|
expect(formatDuration(3600)).toBe("1 h 0 min");
|
|
expect(formatDuration(93784)).toBe("1 d 2 h 3 min");
|
|
expect(formatDuration(86400)).toBe("1 d 0 h 0 min");
|
|
});
|
|
});
|