26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import { getComposerHeight } from '../app/utils/composer-size';
|
|
|
|
describe('composer height stability', () => {
|
|
test('subpixel noise never oscillates around the two-line minimum', () => {
|
|
const heights = [47.99999, 48, 48.01].map(height => getComposerHeight(height, 24, 0, 0, true));
|
|
expect(heights).toEqual([48, 48, 48]);
|
|
});
|
|
|
|
test('grows and shrinks for actual lines, capped at ten lines', () => {
|
|
expect([24, 48, 72, 264, 72, 24].map(height => getComposerHeight(height, 24, 0, 0, true)))
|
|
.toEqual([48, 48, 72, 240, 72, 48]);
|
|
});
|
|
|
|
test('accounts for padding and borders according to box sizing', () => {
|
|
expect(getComposerHeight(80, 24, 8, 2, true)).toBe(82);
|
|
expect(getComposerHeight(80, 24, 8, 2, false)).toBe(72);
|
|
expect(getComposerHeight(10, 24, 8, 2, true)).toBe(58);
|
|
});
|
|
|
|
test('respects fractional typography rather than hardcoding a 24px line', () => {
|
|
expect(getComposerHeight(40, 20.25, 0, 0, true)).toBe(41);
|
|
expect(getComposerHeight(1000, 20.25, 0, 0, true)).toBe(203);
|
|
});
|
|
});
|