25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { getNextRepeatDate, parseReminderDate } from "../src/utils/date";
|
|
|
|
const base = new Date("2026-06-27T10:00:00");
|
|
|
|
const plusTwoHours = parseReminderDate("+2h", base);
|
|
assert.equal(plusTwoHours?.toISOString(), new Date("2026-06-27T12:00:00").toISOString());
|
|
|
|
const tomorrow = parseReminderDate("tomorrow 09:30", base);
|
|
assert.equal(tomorrow?.toISOString(), new Date("2026-06-28T09:30:00").toISOString());
|
|
|
|
const simple = parseReminderDate("2026-07-01 14:46", base);
|
|
assert.equal(simple?.getFullYear(), 2026);
|
|
assert.equal(simple?.getMonth(), 6);
|
|
assert.equal(simple?.getDate(), 1);
|
|
assert.equal(simple?.getHours(), 14);
|
|
assert.equal(simple?.getMinutes(), 46);
|
|
|
|
const nextDaily = getNextRepeatDate("2026-06-26T10:00:00.000Z", { frequency: "daily", interval: 1 }, new Date("2026-06-27T10:00:01.000Z"));
|
|
assert.equal(nextDaily, "2026-06-28T10:00:00.000Z");
|
|
|
|
const nextWeekly = getNextRepeatDate("2026-06-20T10:00:00.000Z", { frequency: "weekly", interval: 2 }, new Date("2026-06-27T10:00:01.000Z"));
|
|
assert.equal(nextWeekly, "2026-07-04T10:00:00.000Z");
|
|
|