The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
import { describe, expect, it } from 'vitest'
import { truncateText } from './job-state'
describe('truncateText', () => {
it('truncates on Unicode code-point boundaries', () => {
const result = truncateText('๐๐๐๐', 3)
expect(result).toBe('๐๐๐โฆ')
expect(Array.from(result)).toEqual(['๐', '๐', '๐', 'โฆ'])
})
it('does not add an ellipsis at the limit', () => {
expect(truncateText('๐๐๐', 3)).toBe('๐๐๐')
})
// Grapheme clusters, not code points: the same shapes profile-glyph.test.tsx pins for the
// profile rail. A job name is raw user input, so these are plausible values, not exotica.
it('never cuts a grapheme cluster mid-sequence', () => {
const cases: Array<[string, number, string]> = [
['๐จ๐ณxy', 1, '๐จ๐ณโฆ'],
['๐จ๐ณxy', 3, '๐จ๐ณxy'],
['๐๐ฝx', 1, '๐๐ฝโฆ'],
['e\u0301x', 1, 'e\u0301โฆ'],
['๐จโ๐ฉโ๐งโ๐ฆxyz', 1, '๐จโ๐ฉโ๐งโ๐ฆโฆ'],
['๐จโ๐ฉโ๐งโ๐ฆxyz', 3, '๐จโ๐ฉโ๐งโ๐ฆxyโฆ'],
['1๏ธโฃ ๆฏๆฅ็ฎๆฅ', 1, '1๏ธโฃโฆ']
]
for (const [value, max, expected] of cases) {
expect(truncateText(value, max)).toBe(expected)
}
})
})