import { describe, expect, it, } from 'vitest'; import { computeStrutHeight } from './computeStrutHeight'; describe('computeStrutHeight', () => { it('uses the centering height when the line-height is generous', () => { // centering = 40/2 + 16*0.34 = 25.44; floor = 16*1.1 = 17.6 → centering wins. expect(computeStrutHeight(40, 16)).toBeCloseTo(25.44, 5); }); it('falls back to the ascent floor when the line-height is tight', () => { // centering = 16/2 + 16*0.34 = 13.44; floor = 16*1.1 = 17.6 → floor wins. expect(computeStrutHeight(16, 16)).toBeCloseTo(17.6, 5); }); it('treats the floor and centering height as equal at the crossover line-height', () => { // centering == floor when lineHeight = 1.52 * fontSize → 24.32 for 16px. expect(computeStrutHeight(24.32, 16)).toBeCloseTo(17.6, 5); }); it('scales with font size', () => { // centering = 60/2 + 32*0.34 = 40.88; floor = 32*1.1 = 35.2 → centering wins. expect(computeStrutHeight(60, 32)).toBeCloseTo(40.88, 5); }); });