import { PixelRatio } from "react-native";
import { withAdjustedLineHeight } from "..";

const FONT_SCALE = 1.118;
jest.spyOn(PixelRatio, "getFontScale").mockReturnValue(FONT_SCALE);

describe("withAdjustedLineHeight", () => {
  it("with provided fontScale and styles", () => {
    // setup
    const styles = {
      lineHeight: 10,
    };

    // run
    const result = withAdjustedLineHeight(styles);

    // verify
    expect(result).toEqual({
      lineHeight: styles.lineHeight * FONT_SCALE,
    });
  });

  it("with provided fontScale and empty styles", () => {
    // setup
    const styles = {};

    // run
    const result = withAdjustedLineHeight(styles);

    // verify
    expect(result).toEqual(styles);
  });

  it("with non-number lineHeight", () => {
    // setup
    const styles = {
      lineHeight: NaN,
    };

    // run
    const result = withAdjustedLineHeight(styles);

    // verify
    expect(result).toEqual(styles);
  });
});
