"use strict";

var React = _interopRequireWildcard(require("react"));

var _enzyme = require("enzyme");

var _themes = require("../../themes");

var _styledComponents = require("../styled-components");

var _constants = require("../constants");

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

/*
Copyright (c) 2018 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
function makeTest(_ref) {
  var title = _ref.title,
      Component = _ref.component,
      _ref$props = _ref.props,
      props = _ref$props === void 0 ? {} : _ref$props,
      _ref$children = _ref.children,
      children = _ref$children === void 0 ? null : _ref$children,
      _ref$snapshotName = _ref.snapshotName,
      snapshotName = _ref$snapshotName === void 0 ? 'correct styles' : _ref$snapshotName;
  // $FlowFixMe
  test(title, function () {
    // $FlowFixMe
    var shallowed = (0, _enzyme.shallow)(React.createElement(Component, props, children));
    expect(shallowed.instance().getStyles()).toMatchSnapshot(snapshotName);
  });
}

var allKinds = Object.values(_constants.KIND);
var allSizes = Object.values(_constants.SIZE);
var allShapes = Object.values(_constants.SHAPE);
var allLoadingStates = [false, true];
describe('Button Styled Components', function () {
  allKinds.forEach(function ($kind) {
    allLoadingStates.forEach(function ($isLoading) {
      // $FlowFixMe
      test("getStyleForKind ".concat($kind, " and loading ").concat($isLoading), function () {
        expect( // $FlowFixMe
        (0, _styledComponents.getStyleForKind)({
          $theme: _themes.LightTheme,
          $kind: $kind,
          $isLoading: $isLoading
        })).toMatchSnapshot();
      });
    });
  });
  allShapes.forEach(function ($shape) {
    allSizes.forEach(function ($size) {
      // $FlowFixMe
      test("getStyleForShape ".concat($shape, " ").concat($size), function () {
        expect( // $FlowFixMe
        (0, _styledComponents.getStyleForShape)({
          $theme: _themes.LightTheme,
          $shape: $shape,
          $size: $size
        })).toMatchSnapshot();
      });
    });
  });
  allShapes.forEach(function (shape) {
    makeTest({
      title: "BaseButton - basic render",
      component: _styledComponents.BaseButton
    });
  });
  test("BaseButton - respects useRoundedCorners", function () {
    var theme = (0, _themes.createTheme)(_themes.lightThemePrimitives, {
      borders: {
        useRoundedCorners: false
      }
    });
    var rendered = (0, _enzyme.shallow)(React.createElement(_styledComponents.BaseButton, {
      $theme: theme
    }, "Test"));
    expect(rendered.instance().getStyles().borderRadius).toMatch('0px');
  });
  makeTest({
    title: 'StartEnhancer - basic render',
    component: _styledComponents.StartEnhancer
  });
  makeTest({
    title: 'EndEnhancer - basic render',
    component: _styledComponents.EndEnhancer
  });
});