diff options
Diffstat (limited to 'desktop/island/calendar/test_cal.js')
| -rw-r--r-- | desktop/island/calendar/test_cal.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/desktop/island/calendar/test_cal.js b/desktop/island/calendar/test_cal.js index de3d1c7..853cbb6 100644 --- a/desktop/island/calendar/test_cal.js +++ b/desktop/island/calendar/test_cal.js @@ -17,7 +17,7 @@ const assert = require("assert"); const src = fs.readFileSync(__dirname + "/Cal.js", "utf8").replace(/^\.pragma library$/m, ""); const C = new Function(src + "\nreturn { pad, addDays, today, daysBetween, monthCells, shiftMonth," + - " lastDay, onDay, dayEvents, dots, timeLabel, validTime, normTime, stepTime, newDraft, fromEvent, pick," + + " lastDay, onDay, dayEvents, dots, timeLabel, validTime, normTime, stepTime, newDraft, withStart, fromEvent, pick," + " toPayload };")(); // Dates are plain YYYY-MM-DD strings, arithmetic in UTC so DST never moves a day. @@ -91,6 +91,17 @@ assert.strictEqual(d.alarm, "1h"); assert.strictEqual(d.calendar, "home"); assert.strictEqual(d.source, ""); assert.strictEqual(C.newDraft("2026-10-20", new Date(2026, 9, 13, 23, 10), "home").startTime, "22:00"); +assert.strictEqual(C.newDraft("2026-10-20", new Date(2026, 9, 13, 9, 20), "home", 90).endTime, "11:30"); + +// The end follows the start, by the default length, past midnight too. +const w = C.withStart(d, "23:30", 60); +assert.strictEqual(w.startTime, "23:30"); +assert.strictEqual(w.endTime, "00:30"); +assert.strictEqual(w.endDay, "2026-10-21"); +assert.strictEqual(C.withStart(d, "14:00", 45).endTime, "14:45"); +assert.strictEqual(C.withStart(d, "9.3", 60).endTime, "11:00"); +const multi = Object.assign({}, d, { endDay: "2026-10-22", endTime: "18:00" }); +assert.strictEqual(C.withStart(multi, "08:00", 60).endTime, "18:00"); // From calctl's JSON. const fe = C.fromEvent({ uid: "u", calendar: "home", title: "Trip", allDay: true, start: "2026-10-14", |
