mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-05 00:07:36 +00:00
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.
25 lines
959 B
TypeScript
25 lines
959 B
TypeScript
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');
|
||
});
|
||
});
|