Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

id.test.ts

20 lines562 Bytes

1import { describe, it, expect } from 'vitest'
2import { generateId } from '../src/id'
3​
4describe('generateId', () => {
5 it('should generate an id with the given prefix', () => {
6 const id = generateId('run')
7 expect(id).toMatch(/^run-\d+-[a-z0-9]+$/)
8 })
9​
10 it('should generate unique ids', () => {
11 const id1 = generateId('msg')
12 const id2 = generateId('msg')
13 expect(id1).not.toBe(id2)
14 })
15​
16 it('should use the prefix exactly as given', () => {
17 const id = generateId('tool_call')
18 expect(id.startsWith('tool_call-')).toBe(true)
19 })
20})