Files
native/src/lib/__tests__/single-line.test.ts
T
Linus Rath d45c7996d2 fix: keep list previews and subjects on one line
Previews keep the body's paragraph breaks, so a line-clamped row showed
a dangling "…" line and rows came out at uneven heights, and a subject
carrying CR/LF rendered over several lines in the list and the viewer.
Fold every whitespace run to a single space before display with a new
`singleLine` helper, in the mailbox and unified inbox rows, the viewer
subject and the collapsed thread card preview.
2026-09-24 18:50:55 +02:00

25 lines
959 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, it, expect } from 'vitest';
import { singleLine } from '../single-line';
describe('singleLine', () => {
it('folds preview paragraph breaks into single spaces', () => {
expect(singleLine('Q3 revenue is up 12 %.\n\n…')).toBe('Q3 revenue is up 12 %. …');
expect(singleLine('Hi team,\r\n\r\nthe numbers\tare in. See below.\n')).toBe('Hi team, the numbers are in. See below.');
});
it('folds a subject carrying CR/LF onto one line', () => {
expect(singleLine('Invoice 1042\r\n for September')).toBe('Invoice 1042 for September');
});
it('returns an empty string for missing or blank input', () => {
expect(singleLine(undefined)).toBe('');
expect(singleLine(null)).toBe('');
expect(singleLine(' \r\n\t ')).toBe('');
});
it('keeps a lone no-break space but folds runs that contain one', () => {
expect(singleLine('12 %')).toBe('12 %');
expect(singleLine('a \nb')).toBe('a b');
});
});