"use strict";

var _react = _interopRequireDefault(require("react"));
var _styleProperties = require("../src/style-properties");
var _typeHelpers = require("../utils/type-helpers");
var _index = require("../src/base/index");
var _reactNative = require("react-native");
var _styleFunctions = require("../src/style-functions");
var _reactNative2 = require("@testing-library/react-native");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
jest.useFakeTimers();
const ColorTransformTestComponent = ({
  props,
  stylePropertyName,
  styleFunction
}) => {
  let value;
  try {
    value = styleFunction.func(props, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
  } catch (e) {
    value = e.message;
  }
  if (typeof value === "object") {
    return /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
      testID: stylePropertyName
    }, value[stylePropertyName]);
  }
  return /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
    testID: "Error"
  }, value);
};
describe("createStyleFunctions", () => {
  it("maps backgroundColor prop correctly", () => {
    const {
      getByText
    } = (0, _reactNative2.render)( /*#__PURE__*/_react.default.createElement(ColorTransformTestComponent, {
      props: {
        backgroundColor: "white"
      },
      stylePropertyName: "backgroundColor",
      styleFunction: _styleFunctions.backgroundColorStyleFunction[0]
    }));
    const targetBackgroundColor = _index.baseTheme["palette"].white;
    expect(getByText(targetBackgroundColor)).toBeTruthy();
  });
  it("maps bg prop correctly", () => {
    const {
      getByText
    } = (0, _reactNative2.render)( /*#__PURE__*/_react.default.createElement(ColorTransformTestComponent, {
      props: {
        bgColor: "white"
      },
      stylePropertyName: "backgroundColor",
      styleFunction: _styleFunctions.backgroundColorStyleFunction[1]
    }));
    const targetBackgroundColor = _index.baseTheme["palette"].white;
    expect(getByText(targetBackgroundColor)).toBeTruthy();
  });
  it("maps color prop correctly", () => {
    const {
      getByText
    } = (0, _reactNative2.render)( /*#__PURE__*/_react.default.createElement(ColorTransformTestComponent, {
      props: {
        color: "white"
      },
      stylePropertyName: "color",
      styleFunction: _styleFunctions.colorStyleFunction
    }));
    const targetColor = _index.baseTheme["palette"].white;
    expect(getByText(targetColor)).toBeTruthy();
  });
  it("maps oapcity prop correctly", () => {
    const props = {
      opacity: 0
    };
    const opacityStyle = _styleFunctions.opacityStyleFunction.func(props, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(opacityStyle.opacity).toBe(0);
  });
  it("maps typography props correctly", () => {
    const props = {
      fontSize: "s"
    };
    const fontSizeStyle = _styleFunctions.typographyStyleFunction[_styleFunctions.typographyStyleFunction.length - 2].func(props, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(fontSizeStyle.fontSize).toBe(14);
    const props2 = {
      lineHeight: "s"
    };
    const lineHeightStyle = _styleFunctions.typographyStyleFunction[_styleFunctions.typographyStyleFunction.length - 1].func(props2, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(lineHeightStyle.lineHeight).toBe(18);
    const props3 = {
      fontFamily: "body"
    };
    const fontFamilyStyle = _styleFunctions.typographyStyleFunction[_styleFunctions.typographyStyleFunction.length - 4].func(props3, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(fontFamilyStyle.fontFamily).toBe("Poppins");
    const props4 = {
      fontWeight: "hairline"
    };
    const fontWeightStyle = _styleFunctions.typographyStyleFunction[_styleFunctions.typographyStyleFunction.length - 3].func(props4, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(fontWeightStyle.fontWeight).toBe("100");
    const props5 = {
      letterSpacing: "xs"
    };
    const letterSpacingStyle = _styleFunctions.typographyStyleFunction[_styleFunctions.typographyStyleFunction.length - 5].func(props5, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(letterSpacingStyle.letterSpacing).toBe(-2);
  });
  it("maps layout props correctly", () => {
    const props = {
      width: 2
    };
    const widthStyle = _styleFunctions.layoutStyleFunction[0].func(props, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(widthStyle.width).toBe(2);
  });
  it("maps spacing props correctly", () => {
    const props1 = {
      margin: "2"
    };
    const spacingStyle1 = _styleFunctions.spacingStyleFunction[0].func(props1, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    const props2 = {
      m: "2"
    };
    const spacingStyle2 = _styleFunctions.spacingStyleFunction[_styleFunctions.spacingStyleFunction.length - 18].func(props2, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(spacingStyle1.margin).toBe(_index.baseTheme.spacing[2]);
    expect(spacingStyle2.margin).toBe(_index.baseTheme.spacing[2]);
  });
  it("maps position props correctly", () => {
    const props = {
      zIndex: "docked"
    };
    const zIndexStyle = _styleFunctions.positionStyleFunction[_styleFunctions.positionStyleFunction.length - 1].func(props, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(zIndexStyle.zIndex).toBe(_index.baseTheme.zIndices.docked);
  });
  it("maps border props correctly", () => {
    const {
      getByText
    } = (0, _reactNative2.render)( /*#__PURE__*/_react.default.createElement(ColorTransformTestComponent, {
      props: {
        borderColor: "black"
      },
      stylePropertyName: "borderColor",
      styleFunction: _styleFunctions.borderStyleFunction[(0, _typeHelpers.getKeys)(_styleProperties.borderProperties).length]
    }));
    const targetBorderColor = _index.baseTheme["palette"].black;
    expect(getByText(targetBorderColor)).toBeTruthy();
    const borderRadiusProps = {
      borderRadius: "s"
    };
    const borderRadiusStyle = _styleFunctions.borderStyleFunction[(0, _typeHelpers.getKeys)(_styleProperties.borderProperties).length + (0, _typeHelpers.getKeys)(_styleProperties.borderColorProperties).length].func(borderRadiusProps, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(borderRadiusStyle.borderRadius).toBe(_index.baseTheme.borderRadii.s);
  });
  it("maps shadow props correctly", () => {
    const props = {
      boxShadow: "s"
    };
    const shadowStyle = _styleFunctions.shadowStyleFunction[_styleFunctions.shadowStyleFunction.length - 2].func(props, {
      theme: _index.baseTheme,
      dimensions: _reactNative.Dimensions.get("window")
    });
    expect(shadowStyle).toBe(_index.baseTheme.elevation.s);
    const {
      getByText
    } = (0, _reactNative2.render)( /*#__PURE__*/_react.default.createElement(ColorTransformTestComponent, {
      props: {
        shadowColor: "neutral.600"
      },
      stylePropertyName: "shadowColor",
      styleFunction: _styleFunctions.shadowStyleFunction[_styleFunctions.shadowStyleFunction.length - 1]
    }));
    const targetShadowColor = (0, _typeHelpers.getNestedObject)(_index.baseTheme, ["palette", "neutral", "600"]);
    expect(getByText(targetShadowColor)).toBeTruthy();
  });
  it("maps textShadow props correctly", () => {
    const {
      getByText
    } = (0, _reactNative2.render)( /*#__PURE__*/_react.default.createElement(ColorTransformTestComponent, {
      props: {
        textShadowColor: "black"
      },
      stylePropertyName: "textShadowColor",
      styleFunction: _styleFunctions.textShadowStyleFunction[_styleFunctions.textShadowStyleFunction.length - 1]
    }));
    const targetTextShadowColor = _index.baseTheme["palette"].black;
    expect(getByText(targetTextShadowColor)).toBeTruthy();
  });
});
//# sourceMappingURL=style-functions.spec.js.map