u
This commit is contained in:
@@ -12,7 +12,7 @@ import assert from 'node:assert/strict';
|
||||
import { createElement as h } from 'react';
|
||||
import { renderToString } from 'ink';
|
||||
|
||||
import { createTurnHandlers, dispatchTurnEvent } from '../src/repl.js';
|
||||
import { createTurnHandlers, dispatchTurnEvent, stampUserInput } from '../src/repl.js';
|
||||
import { TURN_EVENTS, TURN_STATES } from '../src/turn-state.js';
|
||||
import { createStore } from '../src/ui/store.js';
|
||||
import { App } from '../src/ui/app.js';
|
||||
@@ -55,6 +55,21 @@ function playTurn(script) {
|
||||
return { store, observed };
|
||||
}
|
||||
|
||||
test('a user message is prefixed with a zero-padded 24-hour local time', () => {
|
||||
const at = (h, m) => new Date(2026, 8, 17, h, m);
|
||||
assert.equal(stampUserInput('add a test', at(14, 32)), '[14:32] add a test');
|
||||
assert.equal(stampUserInput('list dirs', at(9, 5)), '[09:05] list dirs');
|
||||
assert.equal(stampUserInput('midnight', at(0, 0)), '[00:00] midnight');
|
||||
assert.equal(stampUserInput('last minute', at(23, 59)), '[23:59] last minute');
|
||||
});
|
||||
|
||||
test('the timestamp prefix never touches the text it wraps', () => {
|
||||
const at = new Date(2026, 8, 17, 8, 7);
|
||||
const text = ' run websearch with start_date \n and a second line ';
|
||||
assert.equal(stampUserInput(text, at), `[08:07] ${text}`);
|
||||
assert.equal(stampUserInput('', at), '[08:07] ');
|
||||
});
|
||||
|
||||
test('a plain answer reads as connecting -> streaming', () => {
|
||||
const { observed } = playTurn([
|
||||
{ cb: 'onContent' },
|
||||
|
||||
Reference in New Issue
Block a user