"use strict";

var _react = _interopRequireDefault(require("react"));

var _enzyme = require("enzyme");

var _index = require("../index");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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.
*/
describe('Modal styled components', function () {
  // Basic tests with static styles first
  [['StyledDialogContainer', _index.StyledDialogContainer], ['StyledClose', _index.StyledClose], ['ModalHeader', _index.ModalHeader], ['ModalBody', _index.ModalBody], ['ModalFooter', _index.ModalFooter]].forEach(function (testCase) {
    test("".concat(testCase[0], " - basic render"), function () {
      var TestCaseClass = testCase[1];
      var component = (0, _enzyme.shallow)(_react.default.createElement(TestCaseClass, null));
      expect(component.instance().getStyles()).toMatchSnapshot("".concat(testCase[0], " has correct styles"));
    });
  });
  test('StyledRoot - basic render', function () {
    var component = (0, _enzyme.shallow)(_react.default.createElement(_index.StyledRoot, {
      $isOpen: false
    }));
    expect(component.instance().getStyles()).toMatchSnapshot('StyledBody has correct styles when closed'); // Should have pointer-events none when closed

    component.setProps({
      $isOpen: false
    });
    expect(component.instance().getStyles().pointerEvents).toBe('none');
  });
  test('StyledBackdrop - basic render', function () {
    var component = (0, _enzyme.shallow)(_react.default.createElement(_index.StyledBackdrop, {
      $isOpen: false,
      $isVisible: false
    }));
    expect(component.instance().getStyles()).toMatchSnapshot('StyledBody has correct styles when closed');
    component.setProps({
      $isOpen: true
    });
    expect(component.instance().getStyles().opacity).toBe(0);
    component.setProps({
      $isVisible: true
    });
    expect(component.instance().getStyles().opacity).toBe(1);
    component.setProps({
      $isOpen: false
    });
    expect(component.instance().getStyles().opacity).toBe(0);
    component.setProps({
      $animate: false
    });
    expect(component.instance().getStyles().transitionProperty).toBeUndefined();
  });
  test('StyledDialog - basic render', function () {
    var component = (0, _enzyme.shallow)(_react.default.createElement(_index.StyledDialog, {
      $isOpen: true,
      $isVisible: true
    }));
    expect(component.instance().getStyles()).toMatchSnapshot('StyledDialog has correct styles');
  });
  test('StyledDialog - full width', function () {
    var component = (0, _enzyme.shallow)(_react.default.createElement(_index.StyledDialog, {
      $isOpen: true,
      $isVisible: true,
      $size: _index.SIZE.full
    }));
    var styles = component.instance().getStyles();
    expect(styles.maxWidth).toBe('100%');
    expect(styles.width).toBe('100%');
    expect(styles.alignSelf).toBe('stretch');
  });
  test('StyledDialog - auto width', function () {
    var component = (0, _enzyme.shallow)(_react.default.createElement(_index.StyledDialog, {
      $isOpen: true,
      $isVisible: true,
      $size: _index.SIZE.auto
    }));
    var styles = component.instance().getStyles();
    expect(styles.maxWidth).toBe('100%');
    expect(styles.width).toBe('auto');
    expect(styles.alignSelf).toBeUndefined();
  });
  test('StyledDialog - custom width', function () {
    var component = (0, _enzyme.shallow)(_react.default.createElement(_index.StyledDialog, {
      $isOpen: true,
      $isVisible: true,
      $size: "800px"
    }));
    var styles = component.instance().getStyles();
    expect(styles.maxWidth).toBe('100%');
    expect(styles.width).toBe('800px');
    expect(styles.alignSelf).toBeUndefined();
  });
});