diff options
Diffstat (limited to 'tests/test_dashboard.mjs')
| -rw-r--r-- | tests/test_dashboard.mjs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/test_dashboard.mjs b/tests/test_dashboard.mjs index 2448c38..78fcefc 100644 --- a/tests/test_dashboard.mjs +++ b/tests/test_dashboard.mjs @@ -15,7 +15,7 @@ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import assert from "node:assert/strict"; -import { area, line, push, spendParts, batteryGlyph, HISTORY } from "../static/dashboard.js"; +import { area, line, push, spendParts, batteryGlyph, dueLabel, HISTORY } from "../static/dashboard.js"; import { busy as printing } from "../static/modules/k1c.js"; import { busy as building, planRows } from "../static/modules/sbbuilder.js"; import { busy as live } from "../static/modules/obs.js"; @@ -64,3 +64,10 @@ assert.deepEqual(planRows({ plan: ["a/x", "b/y", "c/z"], progress: { results: { "a/x": "failed" }, current: "b/y" } }).map((r) => r.status), ["failed", "building", "waiting"]); assert.deepEqual(planRows(undefined), []); + +// dueLabel: reminder-only, later today, hours and days overdue +const now = new Date(2026, 10, 30, 12, 0); +assert.equal(dueLabel(null, now), "reminder"); +assert.match(dueLabel(new Date(2026, 10, 30, 15, 0).toISOString(), now), /^today 15.00$/); +assert.equal(dueLabel(new Date(2026, 10, 30, 9, 0).toISOString(), now), "overdue 3h"); +assert.equal(dueLabel(new Date(2026, 10, 27, 12, 0).toISOString(), now), "overdue 3d"); |
