Files
purewhiter--mobilegym/tests/notesReminderPickerModel.test.ts
wehub-resource-sync 2114b14ee0
Sync main into demo / sync (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:26 +08:00

38 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest';
const NOW_TS = new Date('2026-04-22T23:26:00+08:00').getTime();
describe('Notes 提醒时间选择模型', () => {
it('会把非 5 分钟刻度向上取整', async () => {
const { roundUpToReminderStep } = await import('../system/Notes/components/dateTimePickerModel');
expect(roundUpToReminderStep(new Date('2026-04-22T23:18:00+08:00').getTime())).toBe(
new Date('2026-04-22T23:20:00+08:00').getTime(),
);
expect(roundUpToReminderStep(new Date('2026-04-22T23:20:00+08:00').getTime())).toBe(
new Date('2026-04-22T23:20:00+08:00').getTime(),
);
});
it('以上午 00:00 的今天为锚点计算最晚可选时间', async () => {
const { getReminderBounds } = await import('../system/Notes/components/dateTimePickerModel');
expect(getReminderBounds(NOW_TS)).toEqual({
minTs: new Date('2026-04-22T23:30:00+08:00').getTime(),
maxTs: new Date('2027-04-23T11:55:00+08:00').getTime(),
});
});
it('会把初始提醒时间夹到当前可选范围内', async () => {
const { clampReminderSelection } = await import('../system/Notes/components/dateTimePickerModel');
expect(
clampReminderSelection(new Date('2026-04-22T21:03:00+08:00').getTime(), NOW_TS),
).toBe(new Date('2026-04-22T23:30:00+08:00').getTime());
expect(
clampReminderSelection(new Date('2027-04-25T09:00:00+08:00').getTime(), NOW_TS),
).toBe(new Date('2027-04-23T11:55:00+08:00').getTime());
});
});