codeburn/app/renderer/lib/reportMemoKey.test.ts
Aditya Vikram Singh b5f07d1cc7
perf(desktop): keep every destination useful across restarts (#1163)
* perf(desktop): keep every destination useful across restarts

* fix(desktop): label cached reports while they refresh

* fix(desktop): preserve reviewed cache invariants

* fix(desktop): bound durable snapshot work
2026-08-28 14:51:18 -07:00

26 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { reportMemoKey } from './reportMemoKey'
describe('reportMemoKey', () => {
it('rolls Today at the local calendar boundary', () => {
const before = new Date(2026, 7, 28, 23, 59, 59)
const after = new Date(2026, 7, 29, 0, 0, 1)
expect(reportMemoKey('sessions', 'today', 'all', null, '', before))
.not.toBe(reportMemoKey('sessions', 'today', 'all', null, '', after))
})
it('keeps historical horizons stable across a new day', () => {
const before = new Date(2026, 7, 28, 23, 59, 59)
const after = new Date(2026, 7, 29, 0, 0, 1)
expect(reportMemoKey('sessions', 'week', 'all', null, '', before))
.toBe(reportMemoKey('sessions', 'week', 'all', null, '', after))
})
it('rolls Month at the local month boundary', () => {
const august = new Date(2026, 7, 31, 23, 59, 59)
const september = new Date(2026, 8, 1, 0, 0, 1)
expect(reportMemoKey('plans', 'month', 'all', null, '', august))
.not.toBe(reportMemoKey('plans', 'month', 'all', null, '', september))
})
})