Files
memind/temporal-recall-service/event-time-extract.test.mjs
T
john 212ff3ff80 Add User Model Service and Temporal Recall for MeMind V0.1.
Introduce UMS ingest/snapshot pipeline, Context Planner with multi-source recall, runtime context injection, canonical user mapping, and session snapshot loading on auth/me.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-03 23:25:18 +08:00

42 lines
1.4 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
extractEventTime,
itemMatchesTimeWindow,
} from './event-time-extract.mjs';
test('extractEventTime parses 明天下午三点', () => {
const observed = new Date('2026-09-02T12:30:00+08:00');
const result = extractEventTime('明天下午三点去签合同', observed);
assert.equal(result.status, 'planned');
const hourLocal = new Date(result.event_time).getTime();
const expected = new Date('2026-09-03T07:00:00.000Z').getTime();
assert.equal(hourLocal, expected);
});
test('extractEventTime parses weekday', () => {
const observed = new Date('2026-09-03T10:00:00+08:00'); // Wed
const result = extractEventTime('下周五开会', observed);
assert.ok(result.event_time);
assert.equal(result.status, 'planned');
});
test('itemMatchesTimeWindow separates mention vs event', () => {
const time = {
mention_range: {
start: '2026-09-02T00:00:00+08:00',
end: '2026-09-03T00:00:00+08:00',
},
event_range: {
start: '2026-09-03T00:00:00+08:00',
end: '2026-09-04T00:00:00+08:00',
},
};
const item = {
observed_time: '2026-09-02T20:00:00+08:00',
event_time: '2026-09-03T15:00:00+08:00',
};
assert.equal(itemMatchesTimeWindow(item, time, 'MENTIONED_IN'), true);
assert.equal(itemMatchesTimeWindow(item, time, 'PLANNED_IN'), true);
});