Files
orca/src/shared/returned-draft-text.test.ts
T
Brennan Benson b354aab18e fix(mobile-chat): a failed message's text is added to the draft, and an expired resend no longer blocks that text (#25149)
* fix(mobile-chat): a returned message is appended to the draft, and an expired resend id is spent

* test(mobile-chat): leave the idempotent append to the shared rule's own test

* docs(native-chat): say a whitespace-only draft counts as empty

* docs(mobile-chat): don't overclaim where returned text survives
2026-10-05 11:37:26 -07:00

24 lines
986 B
TypeScript

import { describe, expect, it } from 'vitest'
import { appendReturnedDraftText } from './returned-draft-text'
describe('appendReturnedDraftText', () => {
it('fills an empty composer with the returned text as it was typed', () => {
expect(appendReturnedDraftText('', 'ping ')).toBe('ping ')
expect(appendReturnedDraftText(' \n', 'ping')).toBe('ping')
})
it('puts the returned text after a draft, a blank line apart', () => {
expect(appendReturnedDraftText('newer edit\n', 'ping')).toBe('newer edit\n\nping')
})
it('adds nothing when the draft already ends with that text', () => {
expect(appendReturnedDraftText('ping', 'ping')).toBe('ping')
expect(appendReturnedDraftText('first\n\nping\n', 'ping ')).toBe('first\n\nping\n')
expect(appendReturnedDraftText('ping', '')).toBe('ping')
})
it('still appends text that only ends a line of the draft', () => {
expect(appendReturnedDraftText('say ping', 'ping')).toBe('say ping\n\nping')
})
})