"use strict";

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

var _enzyme = require("enzyme");

var _block = _interopRequireDefault(require("../block"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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 retrieveStyles(element) {
  return (0, _enzyme.mount)(element).childAt(0).instance().getStyles();
}

describe('Block', function () {
  it('renders themed color if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      color: "primary200"
    }, "test"))).toMatchObject({
      color: '$theme.colors.primary200'
    });
  });
  it('renders provided color if no matching themeable value is found', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      color: "red"
    }, "test"))).toMatchObject({
      color: 'red'
    });
  });
  it('renders themed font if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      font: "font200"
    }, "test"))).toMatchObject({
      fontFamily: '$theme.typography.font200.fontFamily',
      fontSize: '$theme.typography.font200.fontSize',
      fontWeight: '$theme.typography.font200.fontWeight'
    });
  });
  it('renders alignContent style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      alignContent: "start"
    }, "test"))).toMatchObject({
      alignContent: 'start'
    });
  });
  it('renders alignItems style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      alignItems: "start"
    }, "test"))).toMatchObject({
      alignItems: 'start'
    });
  });
  it('renders flexDirection style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      flexDirection: "row"
    }, "test"))).toMatchObject({
      flexDirection: 'row'
    });
  });
  it('renders display style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      display: "inline-block"
    }, "test"))).toMatchObject({
      display: 'inline-block'
    });
  });
  it('renders flex style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      flex: "grow"
    }, "test"))).toMatchObject({
      flex: 'grow'
    });
  });
  it('renders justifyContent style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      justifyContent: "start"
    }, "test"))).toMatchObject({
      justifyContent: 'start'
    });
  });
  it('renders justifySelf style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      justifySelf: "start"
    }, "test"))).toMatchObject({
      justifySelf: 'start'
    });
  });
  it('renders position style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      position: "static"
    }, "test"))).toMatchObject({
      position: 'static'
    });
  });
  it('renders width style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      width: "100px"
    }, "test"))).toMatchObject({
      width: '100px'
    });
  });
  it('renders minWidth style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      minWidth: "100px"
    }, "test"))).toMatchObject({
      minWidth: '100px'
    });
  });
  it('renders maxWidth style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      maxWidth: "100px"
    }, "test"))).toMatchObject({
      maxWidth: '100px'
    });
  });
  it('renders height style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      height: "100px"
    }, "test"))).toMatchObject({
      height: '100px'
    });
  });
  it('renders minHeight style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      minHeight: "100px"
    }, "test"))).toMatchObject({
      minHeight: '100px'
    });
  });
  it('renders maxHeight style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      maxHeight: "100px"
    }, "test"))).toMatchObject({
      maxHeight: '100px'
    });
  });
  describe('Overflow', function () {
    it('renders overflowX styling if provided with scrollX value', function () {
      expect(retrieveStyles(React.createElement(_block.default, {
        overflow: "scrollX"
      }, "test"))).toMatchObject({
        overflowX: 'scroll'
      });
    });
    it('renders overflowY styling if provided with scrollY value', function () {
      expect(retrieveStyles(React.createElement(_block.default, {
        overflow: "scrollY"
      }, "test"))).toMatchObject({
        overflowY: 'scroll'
      });
    });
    it('renders overflow styling if provided any other value', function () {
      expect(retrieveStyles(React.createElement(_block.default, {
        overflow: "auto"
      }, "test"))).toMatchObject({
        overflow: 'auto'
      });
    });
  });
  it('renders overflow style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      overflow: "hidden"
    }, "test"))).toMatchObject({
      overflow: 'hidden'
    });
  });
  it('renders themed margin style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      margin: "scale200"
    }, "test"))).toMatchObject({
      margin: '$theme.sizing.scale200'
    });
  });
  it('renders themed marginTop style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      marginTop: "scale200"
    }, "test"))).toMatchObject({
      marginTop: '$theme.sizing.scale200'
    });
  });
  it('renders themed marginRight style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      marginRight: "scale200"
    }, "test"))).toMatchObject({
      marginRight: '$theme.sizing.scale200'
    });
  });
  it('renders themed marginBottom style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      marginBottom: "scale200"
    }, "test"))).toMatchObject({
      marginBottom: '$theme.sizing.scale200'
    });
  });
  it('renders themed marginLeft style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      marginLeft: "scale200"
    }, "test"))).toMatchObject({
      marginLeft: '$theme.sizing.scale200'
    });
  });
  it('renders themed padding style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      padding: "scale200"
    }, "test"))).toMatchObject({
      padding: '$theme.sizing.scale200'
    });
  });
  it('renders themed paddingTop style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      paddingTop: "scale200"
    }, "test"))).toMatchObject({
      paddingTop: '$theme.sizing.scale200'
    });
  });
  it('renders themed paddingRight style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      paddingRight: "scale200"
    }, "test"))).toMatchObject({
      paddingRight: '$theme.sizing.scale200'
    });
  });
  it('renders themed paddingBottom style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      paddingBottom: "scale200"
    }, "test"))).toMatchObject({
      paddingBottom: '$theme.sizing.scale200'
    });
  });
  it('renders themed paddingLeft style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      paddingLeft: "scale200"
    }, "test"))).toMatchObject({
      paddingLeft: '$theme.sizing.scale200'
    });
  });
  it('renders flexWrap style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      flexWrap: true
    }, "test"))).toMatchObject({
      flexWrap: 'wrap'
    });
  });
  it('renders left style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      left: "1px"
    }, "test"))).toMatchObject({
      left: '1px'
    });
  });
  it('renders top style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      top: "1px"
    }, "test"))).toMatchObject({
      top: '1px'
    });
  });
  it('renders right style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      right: "1px"
    }, "test"))).toMatchObject({
      right: '1px'
    });
  });
  it('renders bottom style if provided', function () {
    expect(retrieveStyles(React.createElement(_block.default, {
      bottom: "1px"
    }, "test"))).toMatchObject({
      bottom: '1px'
    });
  });
  it('applies other props if provided', function () {
    var onClickMock = jest.fn();
    var example = (0, _enzyme.mount)(React.createElement(_block.default, {
      onClick: onClickMock
    }, "test"));
    example.simulate('click');
    expect(onClickMock).toHaveBeenCalled();
  });
});