From 594912b51673e0785b18c64b021f456eadc17d3f Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Thu, 08 Oct 2026 15:30:40 +0000
Subject: [PATCH] GS-2555
---
test/testKursLp.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/test/testKursLp.js b/test/testKursLp.js
index 14013e4..b79729b 100644
--- a/test/testKursLp.js
+++ b/test/testKursLp.js
@@ -221,6 +221,57 @@
expect(auswerten([item(0, recent()), item(0, recent()), item(0, recent())])).to.equal(0)
})
+ /////// stale dates (outside the one-month ballpark)
+
+ it("stale: should return the status when all items are stale and equal", function () {
+ expect(auswerten([item(2, stale()), item(2, stale())])).to.equal(2)
+ })
+
+ it("stale: should return 1 when all stale items are mixed (0,2)", function () {
+ expect(auswerten([item(0, stale()), item(2, stale())])).to.equal(1)
+ })
+
+ it("stale: should return 3 when all stale items are 3", function () {
+ expect(auswerten([item(3, stale()), item(3, stale())])).to.equal(3)
+ })
+
+ it("stale: should return the status for a single stale item", function () {
+ expect(auswerten([item(2, stale())])).to.equal(2)
+ expect(auswerten([item(3, stale())])).to.equal(3)
+ })
+
+ it("stale: a stale 3 should not force 3 when a recent item exists", function () {
+ expect(auswerten([item(3, stale()), item(2, recent())])).to.equal(1)
+ })
+
+ it("stale: a stale 3 should still force 3 when a recent 3 exists", function () {
+ expect(auswerten([item(3, stale()), item(3, recent())])).to.equal(3)
+ })
+
+ it("stale: should return 1 when all recent statuses are equal but a stale item exists", function () {
+ expect(auswerten([item(0, recent()), item(0, recent()), item(0, stale())])).to.equal(1)
+ })
+
+ it("stale: should return 1 for a recent 2 plus a stale 2", function () {
+ expect(auswerten([item(2, recent()), item(2, stale())])).to.equal(1)
+ })
+
+ it("stale: should ignore a stale item when recent statuses are already mixed", function () {
+ expect(auswerten([item(0, recent()), item(2, recent()), item(0, stale())])).to.equal(1)
+ })
+
+ it("stale: boundary - item just inside the month counts as recent", function () {
+ const now = dayjs()
+ const inside = now.subtract(1, "month").add(1, "day").toDate()
+ expect(auswerten([item(0, now.toDate()), item(0, inside)])).to.equal(0)
+ })
+
+ it("stale: boundary - item just outside the month counts as stale", function () {
+ const now = dayjs()
+ const outside = now.subtract(1, "month").subtract(1, "day").toDate()
+ expect(auswerten([item(0, now.toDate()), item(0, outside)])).to.equal(1)
+ })
+
})
})
--
Gitblit v1.8.0