Files
opencode-manager/backend/test/utils/text-truncate.test.ts
T
Chris Scott b36d412ca2 feat: add multi-run fusion and session change walkthroughs
Fuse two to five completed multi-run entries into one synthesized session,
and explain a session's diff as ordered walkthrough stops cached by diff hash.

- Multi-run fusion service, persistence, routes and FuseRunDialog
- Change walkthrough service, persistence, routes and ChangesWalkthroughDialog
- Shared unified-diff parser plus bounded text generation, json-extract,
  text-truncate and service-error helpers
2026-10-06 15:27:14 -04:00

25 lines
923 B
TypeScript

import { describe, expect, it } from 'vitest'
import { truncateText } from '../../src/utils/text-truncate'
describe('truncateText', () => {
it('returns text unchanged when it is within the limit', () => {
expect(truncateText('hello', 10, '[cut]')).toEqual({ text: 'hello', truncated: false })
})
it('returns text unchanged when it is exactly at the limit', () => {
expect(truncateText('hello', 5, '[cut]')).toEqual({ text: 'hello', truncated: false })
})
it('slices to the limit, appends the marker and reports truncation', () => {
expect(truncateText('hello world', 5, '…')).toEqual({ text: 'hello…', truncated: true })
})
it('supports a zero limit', () => {
expect(truncateText('hello', 0, '[cut]')).toEqual({ text: '[cut]', truncated: true })
})
it('leaves empty text untouched', () => {
expect(truncateText('', 5, '[cut]')).toEqual({ text: '', truncated: false })
})
})