function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/*
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.
*/
import React from 'react';
import { shallow } from 'enzyme';
import { StyledRoot, StyledQuickSelectContainer, StyledQuickSelectLabel, StyledQuickSelectButtons, StyledCalendarContainer, StyledHeader, StyledMonthHeader, StyledMonth, StyledWeek, StyledDay } from '../index.js';
import { calculateBorderRadius as calcRadius } from '../styled-components.js';
var styledComponents = [[StyledRoot, 'StyledRoot'], [StyledQuickSelectContainer, 'StyledQuickSelectContainer'], [StyledQuickSelectLabel, 'StyledQuickSelectLabel'], [StyledQuickSelectButtons, 'StyledQuickSelectButtons'], [StyledCalendarContainer, 'StyledCalendarContainer'], [StyledHeader, 'StyledHeader'], [StyledMonthHeader, 'StyledMonthHeader'], [StyledMonth, 'StyledMonth'], [StyledWeek, 'StyledWeek'], [StyledDay, 'StyledDay']];
var props = [['$disabled'], ['$isHighlighted'], ['$isHovered'], ['$outsideMonth'], ['$selected']];
describe('Component styled components', function () {
  test.each(styledComponents)('Basic render', function (Component, name) {
    var component = shallow(React.createElement(Component, null));
    expect(component.instance().getStyles()).toMatchSnapshot("".concat(name, " has correct styles"));
  });
  test.each(props)('Prop based styles', function (prop) {
    var component = shallow(React.createElement(StyledDay, _defineProperty({}, prop, true)));
    expect(component.instance().getStyles()).toMatchSnapshot("StyledDay has correct styles when ".concat(prop, " is set to true"));
  });
});
describe('Border radius calculation', function () {
  function getProps(overrides) {
    return _objectSpread({
      $date: new Date(),
      $isHighlighted: false,
      $pseudoHighlighted: false,
      $pseudoSelected: false,
      $selected: false,
      $startDate: false,
      $isRange: true,
      $hasRangeHighlighted: false,
      $hasRangeOnRight: false,
      $hasRangeSelected: false,
      $theme: {
        borders: {
          useRoundedCorners: true,
          radius200: '4px'
        }
      }
    }, overrides);
  }

  function toStrVal(obj) {
    return obj ? "".concat(obj.borderTopLeftRadius, " ").concat(obj.borderTopRightRadius, " ").concat(obj.borderBottomRightRadius, " ").concat(obj.borderBottomLeftRadius) : null;
  }

  test('isRange and useRoundedCorners', function () {
    expect(toStrVal(calcRadius(getProps()))).toEqual('4px 4px 4px 4px');
  });
  test('!useRoundedCorners', function () {
    // !useRoundedCorners
    expect(toStrVal(calcRadius(getProps({
      $theme: {
        borders: {
          useRoundedCorners: false,
          radius200: '4px'
        }
      }
    })))).toEqual('0 0 0 0');
  });
  test('$selected', function () {
    // $selected
    expect(toStrVal(calcRadius(getProps({
      $selected: true
    })))).toEqual('4px 4px 4px 4px');
  });
  test('$selected and !isRange', function () {
    // $selected/!$isRange
    expect(toStrVal(calcRadius(getProps({
      $selected: true,
      $isRange: false
    })))).toEqual('4px 4px 4px 4px');
  });
  test('$selected, $hasRangeSelected, and $startDate', function () {
    // $selected/$hasRangeSelected/$startDate
    expect(toStrVal(calcRadius(getProps({
      $selected: true,
      $hasRangeSelected: true,
      $startDate: true
    })))).toEqual('4px 0 0 4px');
  });
  test('$selected, $hasRangeSelected, and !$startDate (endDate)', function () {
    // $selected/$hasRangeSelected/!$startDate(means endDate)
    expect(toStrVal(calcRadius(getProps({
      $selected: true,
      $hasRangeSelected: true
    })))).toEqual('0 4px 4px 0');
  });
  test('$selected, $hasRangeHighlighted, and $hasRangeOnRight', function () {
    // $selected/$hasRangeHighlighted/$hasRangeOnRight
    expect(toStrVal(calcRadius(getProps({
      $selected: true,
      $hasRangeHighlighted: true,
      $hasRangeOnRight: true
    })))).toEqual('4px 0 0 4px');
  });
  test('$selected, $hasRangeHighlighted, and !$hasRangeOnRight(heighlighted range is on the left)', function () {
    // $selected/$hasRangeHighlighted/!$hasRangeOnRight(means heighlighted range is on the left)
    expect(toStrVal(calcRadius(getProps({
      $selected: true,
      $hasRangeHighlighted: true
    })))).toEqual('0 4px 4px 0');
  });
  test('$pseudoHighlighted', function () {
    expect(toStrVal(calcRadius(getProps({
      $pseudoHighlighted: true
    })))).toEqual('0 0 0 0');
  });
  test('$pseudoSelected', function () {
    expect(toStrVal(calcRadius(getProps({
      $pseudoSelected: true
    })))).toEqual('0 0 0 0');
  });
  test('$isHighlighted and !$isRange', function () {
    expect(toStrVal(calcRadius(getProps({
      $isHighlighted: true,
      $isRange: false
    })))).toEqual('4px 4px 4px 4px');
  });
  test('$isHighlighted and $hasRangeHighlighted', function () {
    expect(toStrVal(calcRadius(getProps({
      $isHighlighted: true,
      $hasRangeHighlighted: true
    })))).toEqual('4px 0 0 4px');
  });
  test('$isHighlighted, $hasRangeHighlighted, and $hasRangeOnRight', function () {
    expect(toStrVal(calcRadius(getProps({
      $isHighlighted: true,
      $hasRangeHighlighted: true,
      $hasRangeOnRight: true
    })))).toEqual('0 4px 4px 0');
  });
  test('$isHighlighted and $pseudoSelected', function () {
    expect(toStrVal(calcRadius(getProps({
      $isHighlighted: true,
      $pseudoSelected: true
    })))).toEqual('0 0 0 0');
  });
  test('$isHighlighted', function () {
    expect(toStrVal(calcRadius(getProps({
      $isHighlighted: true
    })))).toEqual('4px 4px 4px 4px');
  });
});