Files
Solaire/tests/freshness.test.ts
oceans2alaska 135be480e5
Some checks failed
CI / verify (push) Has been cancelled
Build the Solaire inventory intelligence MVP
Add the tenant-ready dashboard, freshness and pricing analytics, mock integration adapters, persistence schema, and verification tooling needed for the initial pilot.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-25 12:16:52 -07:00

26 lines
805 B
TypeScript

import { describe, expect, it } from "vitest";
import { calculateFreshness, freshnessStatus } from "@/domain/freshness";
describe("freshness scoring", () => {
const asOf = new Date("2026-07-25T12:00:00Z");
it("returns a fresh score for recently received stock", () => {
expect(calculateFreshness("2026-07-23T12:00:00Z", 10, asOf)).toMatchObject({
ageDays: 2,
remainingDays: 8,
score: 80,
status: "fresh",
});
});
it("marks the threshold states consistently", () => {
expect(freshnessStatus(45)).toBe("watch");
expect(freshnessStatus(20)).toBe("at_risk");
expect(freshnessStatus(0)).toBe("expired");
});
it("never emits a negative freshness score", () => {
expect(calculateFreshness("2026-07-01T12:00:00Z", 7, asOf).score).toBe(0);
});
});