mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
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
25 lines
923 B
TypeScript
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 })
|
|
})
|
|
})
|