mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-27 01:11:40 +00:00
feat: add tests and update mds
This commit is contained in:
parent
f226e6be10
commit
9d8f9765c1
11 changed files with 6013 additions and 4 deletions
25
ui-tui/src/__tests__/messages.test.ts
Normal file
25
ui-tui/src/__tests__/messages.test.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { upsert } from '../lib/messages.js'
|
||||
|
||||
|
||||
describe('upsert', () => {
|
||||
|
||||
it('appends when last role differs', () => {
|
||||
expect(upsert([{ role: 'user', text: 'hi' }], 'assistant', 'hello')).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('replaces when last role matches', () => {
|
||||
expect(upsert([{ role: 'assistant', text: 'partial' }], 'assistant', 'full')[0]!.text).toBe('full')
|
||||
})
|
||||
|
||||
it('appends to empty', () => {
|
||||
expect(upsert([], 'user', 'first')).toEqual([{ role: 'user', text: 'first' }])
|
||||
})
|
||||
|
||||
it('does not mutate', () => {
|
||||
const prev = [{ role: 'user' as const, text: 'hi' }]
|
||||
upsert(prev, 'assistant', 'yo')
|
||||
expect(prev).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue