import { jsx as ___EmotionJSX } from "@emotion/core";
import React from 'react';
import PropTypes from 'prop-types';
import { shallow } from 'enzyme';
import allowNullPropType from './index';

var Test = function Test(_ref) {
  var text = _ref.text;
  return ___EmotionJSX("p", null, text || 'Some text');
};

Test.propTypes = {
  text: allowNullPropType(PropTypes.string.isRequired)
};
/* eslint-disable no-console */

describe('allowNullPropType', function () {
  it('raises an error if no prop is passed in', function () {
    console.error = jest.fn();
    shallow(___EmotionJSX(Test, null));
    expect(console.error).toHaveBeenCalled();
  });
  it('does not raise error with null prop', function () {
    console.error = jest.fn();
    shallow(___EmotionJSX(Test, {
      text: null
    }));
    expect(console.error).not.toHaveBeenCalled();
  });
  it('does not raise error with normal prop', function () {
    console.error = jest.fn();
    shallow(___EmotionJSX(Test, {
      text: "Sample text!"
    }));
    expect(console.error).not.toHaveBeenCalled();
  });
});
/* eslint-enable no-console */