import assert from 'node:assert/strict';
import test from 'node:test';
import { parseScheduleIntent } from './schedule-intent.mjs';
import { nextDailyRunAt } from './schedule-time.mjs';

test('parses daily 7am todo digest request', () => {
  const intent = parseScheduleIntent('每天早上 7 点给我发一天的待办记录');
  assert.equal(intent.action, 'create_daily_todo_digest');
  assert.equal(intent.hour, 7);
  assert.equal(intent.minute, 0);
});

test('daily todo digest asks for time when missing', () => {
  const intent = parseScheduleIntent('每天给我发一天的待办记录');
  assert.equal(intent.action, 'create_daily_todo_digest');
  assert.deepEqual(intent.needsClarification, ['digest_time']);
});

test('nextDailyRunAt rolls to tomorrow when today time has passed', () => {
  const now = Date.UTC(2026, 5, 17, 23, 30, 0); // 2026-06-18 07:30 Asia/Shanghai
  const next = nextDailyRunAt({ hour: 7, minute: 0, timezone: 'Asia/Shanghai', now });
  assert.equal(next, Date.UTC(2026, 5, 18, 23, 0, 0)); // 2026-06-19 07:00 Asia/Shanghai
});
