import { FontStylesType } from "../../Font/types"; import commonGetter from "./commonGetter"; const mockTokens = { body: { data: { weight: 100, }, }, } as FontStylesType["web"]; describe("commonGetter", () => { it("should return the expected object shape given input tokens", () => { const result = commonGetter({ platform: "web", tokens: mockTokens, getValue: ({ weight }) => weight, }); expect(result).toEqual({ body: 100, }); }); it("should include the correct value based on the platform", () => { const result = commonGetter({ platform: "web", tokens: mockTokens, getValue: ({ weight }, platform) => platform === "web" ? `${weight}px` : weight, additionalValues: { foo: 300 }, }); expect(result).toEqual({ body: "100px", foo: 300, }); }); it("should include any additional values", () => { const result = commonGetter({ platform: "web", tokens: mockTokens, getValue: ({ weight }) => weight, additionalValues: { foo: 300 }, }); expect(result).toEqual({ body: 100, foo: 300, }); }); it("should include the correct additionalValue based on the platform", () => { const getValue = ({ weight }, platform) => platform === "web" ? `${weight}px` : weight; const result = commonGetter({ platform: "web", tokens: mockTokens, getValue, additionalValues: { foo: getValue({ weight: 200 }, "web") }, }); expect(result).toEqual({ body: "100px", foo: "200px", }); }); });