import { describe, expect, it } from "vitest"; import { getStepIndexByValue, letterSpacingSteps, lineHeightSteps, normalizeFontPickerValue, } from "./font-picker-value"; describe("FontPicker letter spacing", () => { it("centers the default zero between three mirrored negative and positive steps", () => { expect(letterSpacingSteps.map(({ numericValue }) => numericValue)).toEqual([ -0.1, -0.05, -0.025, 0, 0.025, 0.05, 0.1, ]); const value = normalizeFontPickerValue(undefined); expect(value.letterSpacing).toBe("normal"); expect( getStepIndexByValue(letterSpacingSteps, value.letterSpacing, "normal"), ).toBe((letterSpacingSteps.length - 1) / 2); }); }); describe("FontPicker line height", () => { it("centers normal leading between three mirrored decrease and increase steps", () => { expect(lineHeightSteps.map(({ numericValue }) => numericValue)).toEqual([ 1, 1.25, 1.375, 1.5, 1.625, 1.75, 2, ]); const value = normalizeFontPickerValue(undefined); expect(value.lineHeight).toBe("normal"); expect( getStepIndexByValue(lineHeightSteps, value.lineHeight, "normal"), ).toBe((lineHeightSteps.length - 1) / 2); expect( lineHeightSteps.map(({ numericValue }) => numericValue - 1.5), ).toEqual([-0.5, -0.25, -0.125, 0, 0.125, 0.25, 0.5]); }); });