"use strict";

var _react = _interopRequireWildcard(require("react"));
var _text = _interopRequireDefault(require("../../components/atoms/text/text"));
var _reactNative = require("@testing-library/react-native");
var _themeContext = require("../../theme/src/theme-context");
var _box = _interopRequireDefault(require("../../components/atoms/box/box"));
var _reactNative2 = require("react-native");
var _useColorScheme = require("../useColorScheme");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
jest.useFakeTimers();
const TestComponent = props => {
  const [useScheme, setUseScheme] = (0, _react.useState)(false);
  const updatedObj = (0, _useColorScheme.useColorScheme)(props.colorScheme, props.object);
  return /*#__PURE__*/_react.default.createElement(_box.default, null, /*#__PURE__*/_react.default.createElement(_text.default, null, useScheme ? updatedObj.color : props.object.color), /*#__PURE__*/_react.default.createElement(_reactNative2.Pressable, {
    onPress: () => setUseScheme(true),
    testID: "switchButton"
  }, "Use color scheme"));
};
describe("useColorScheme", () => {
  it("leaves values unchanged for missing color scheme", () => {
    const {
      getByText,
      getByTestId
    } = (0, _reactNative.render)( /*#__PURE__*/_react.default.createElement(_themeContext.ThemeProvider, null, /*#__PURE__*/_react.default.createElement(TestComponent, {
      colorScheme: null,
      object: {
        color: "primary100",
        fontSize: 20
      }
    })));
    expect(getByText("primary100")).toBeTruthy();
    const toggleButton = getByTestId("switchButton");
    _reactNative.fireEvent.press(toggleButton);
    expect(getByText("primary100")).toBeTruthy();
  });
  it("switches values containing primary to secondary", () => {
    const {
      getByText,
      getByTestId
    } = (0, _reactNative.render)( /*#__PURE__*/_react.default.createElement(_themeContext.ThemeProvider, null, /*#__PURE__*/_react.default.createElement(TestComponent, {
      colorScheme: "secondary",
      object: {
        color: "primary100",
        fontSize: 20
      }
    })));
    expect(getByText("primary100")).toBeTruthy();
    const toggleButton = getByTestId("switchButton");
    _reactNative.fireEvent.press(toggleButton);
    expect(getByText("secondary100")).toBeTruthy();
  });
});
//# sourceMappingURL=useColorScheme.spec.js.map