Observed behavior
In src/agents/__test__/test-agent.test.ts, the should return preset results in FIFO order test has an inline comment that contradicts both the assertions immediately below it and the implementation in src/agents/test.ts:
agent.setNextInvokeResult(first, second);
// FIFO: second is returned first (pop from end)
expect(await agent.invoke('prompt2')).toStrictEqual(first);
expect(await agent.invoke('prompt1')).toStrictEqual(second);
The comment claims FIFO means "second is returned first (pop from end)", but:
- FIFO (first-in-first-out) means the first inserted result is returned first.
- The assertions correctly verify that: the first invoke returns
first, the second invoke returns second.
TestAgent.invoke uses this.#results.shift(), which removes from the front of the array, not the end.
So the test name and the assertions are correct; only the comment is wrong. The comment also misnames the prompts ('prompt2' is passed on the first invoke, 'prompt1' on the second) which adds to the confusion. The same swap on the prompt strings appears intentional only if the reader believed the misleading comment.
Expected behavior
The comment should describe the actual behaviour, for example:
// FIFO: first inserted is returned first (shift from front)
expect(await agent.invoke('prompt1')).toStrictEqual(first);
expect(await agent.invoke('prompt2')).toStrictEqual(second);
Minimal reproduction
Read src/agents/__test__/test-agent.test.ts lines 17 to 27. The behaviour is correct; only the comment is wrong, which makes the test confusing on first read.
Suggested fix
- Replace the comment with an accurate description (
FIFO: first inserted is returned first (shift from front)).
- Swap the prompt string arguments (
'prompt1' first, then 'prompt2') so they line up with the order they are submitted.
Observed behavior
In
src/agents/__test__/test-agent.test.ts, theshould return preset results in FIFO ordertest has an inline comment that contradicts both the assertions immediately below it and the implementation insrc/agents/test.ts:The comment claims FIFO means "second is returned first (pop from end)", but:
first, the second invoke returnssecond.TestAgent.invokeusesthis.#results.shift(), which removes from the front of the array, not the end.So the test name and the assertions are correct; only the comment is wrong. The comment also misnames the prompts (
'prompt2'is passed on the first invoke,'prompt1'on the second) which adds to the confusion. The same swap on the prompt strings appears intentional only if the reader believed the misleading comment.Expected behavior
The comment should describe the actual behaviour, for example:
Minimal reproduction
Read
src/agents/__test__/test-agent.test.tslines 17 to 27. The behaviour is correct; only the comment is wrong, which makes the test confusing on first read.Suggested fix
FIFO: first inserted is returned first (shift from front)).'prompt1'first, then'prompt2') so they line up with the order they are submitted.