favicon and some TODOs
This commit is contained in:
@@ -27,6 +27,8 @@ function sel(overrides: Partial<Selections> = {}): Selections {
|
||||
targetDate: d("2026-04-10"),
|
||||
activeMissingPeriodIds: new Set(),
|
||||
extraExcludedDays: 0,
|
||||
actualMealBlocks: null,
|
||||
actualFlexDollars: null,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -95,4 +97,51 @@ describe("estimate", () => {
|
||||
expect(r.consumedMealBlocks).toBe(0);
|
||||
expect(Number.isFinite(r.remainingMealBlocks)).toBe(true);
|
||||
});
|
||||
|
||||
it("reports activeDaysRemaining as total minus consumed", () => {
|
||||
// Halfway: Jan 1 .. Feb 19 is 50 inclusive days of a 100-day window.
|
||||
const r = estimate(config, sel({ targetDate: d("2026-02-19") }));
|
||||
expect(r.activeDaysConsumed).toBe(50);
|
||||
expect(r.activeDaysRemaining).toBe(50);
|
||||
});
|
||||
|
||||
it("returns null comparisons when no actual balance is entered", () => {
|
||||
const r = estimate(config, sel());
|
||||
expect(r.blockComparison).toBeNull();
|
||||
expect(r.flexComparison).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("balance comparison", () => {
|
||||
// Halfway through the 100-day window: expected remaining = 100 blocks / 250 flex.
|
||||
const halfway = () => sel({ targetDate: d("2026-02-19") });
|
||||
|
||||
it("flags a higher-than-expected balance as ahead", () => {
|
||||
const r = estimate(config, { ...halfway(), actualMealBlocks: 130 });
|
||||
expect(r.blockComparison?.status).toBe("ahead");
|
||||
expect(r.blockComparison?.difference).toBeCloseTo(30);
|
||||
});
|
||||
|
||||
it("flags a lower-than-expected balance as behind", () => {
|
||||
const r = estimate(config, { ...halfway(), actualMealBlocks: 70 });
|
||||
expect(r.blockComparison?.status).toBe("behind");
|
||||
expect(r.blockComparison?.difference).toBeCloseTo(-30);
|
||||
});
|
||||
|
||||
it("flags a matching balance as on track", () => {
|
||||
const r = estimate(config, { ...halfway(), actualMealBlocks: 100 });
|
||||
expect(r.blockComparison?.status).toBe("onTrack");
|
||||
});
|
||||
|
||||
it("suggests a go-forward per-week rate from the actual balance", () => {
|
||||
// 130 blocks over 50 remaining days => 2.6/day => 18.2/week.
|
||||
const r = estimate(config, { ...halfway(), actualMealBlocks: 130 });
|
||||
expect(r.blockComparison?.suggestedPerWeek).toBeCloseTo(18.2, 1);
|
||||
});
|
||||
|
||||
it("suggests null per-week when no active days remain", () => {
|
||||
const r = estimate(config, { ...sel(), actualMealBlocks: 0 });
|
||||
expect(r.activeDaysRemaining).toBe(0);
|
||||
expect(r.blockComparison?.suggestedPerWeek).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user