REST Service for POPCORN - ILIAS
alex
8 hours ago 594912b51673e0785b18c64b021f456eadc17d3f
GS-2555
1 files modified
51 ■■■■■ changed files
test/testKursLp.js 51 ●●●●● patch | view | raw | blame | history
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)
      })
   })
})