UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

82 lines 3.93 kB
import React from 'react'; import { shallow } from 'enzyme'; import assert from 'assert'; import { common } from '../../util/generic-tests'; import Panel from './Panel'; describe('Panel', function () { common(Panel); describe('render', function () { it('should render any children that are not instances of `Panel.Header` or `Panel.Footer`', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null, /*#__PURE__*/React.createElement(Panel.Header, null, "Header"), "A Cool Content", /*#__PURE__*/React.createElement(Panel.Footer, null, "Footer"))); assert.equal(wrapper.find('.lucid-Panel-content').length, 1); assert(wrapper.contains('A Cool Content')); }); }); describe('props', function () { describe('isGutterless', function () { it('should apply the correct class', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null)); assert.equal(wrapper.find('.lucid-Panel-is-not-gutterless').length, 1); }); }); describe('hasMargin', function () { it('should apply the correct class', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null)); assert(wrapper.hasClass('lucid-Panel-has-margin')); }); it('should not apply the class', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, { hasMargin: false })); assert(!wrapper.hasClass('lucid-Panel-has-margin')); }); }); describe('isScrollable', function () { it('should apply the correct class', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null)); assert(wrapper.hasClass('lucid-Panel-is-scrollable')); }); it('should not apply the class', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, { isScrollable: false })); assert(!wrapper.hasClass('lucid-Panel-is-scrollable')); }); }); }); describe('childComponents', function () { describe('Header', function () { it('should render', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null, /*#__PURE__*/React.createElement(Panel.Header, null, "Header"), "Content")); assert.equal(wrapper.find('.lucid-Panel-Header').length, 1); }); it('should not render when not included', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null, "Content")); assert.equal(wrapper.find('.lucid-Panel-Header').length, 0); }); it('should pass through className', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null, /*#__PURE__*/React.createElement(Panel.Header, { className: "foo" }, "Header"), "Content")); assert.equal(wrapper.find('.lucid-Panel-Header.foo').length, 1); }); }); describe('Footer', function () { it('should render', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null, "Content", /*#__PURE__*/React.createElement(Panel.Footer, null, /*#__PURE__*/React.createElement("button", null, "Save")))); assert.equal(wrapper.find('.lucid-Panel-Footer').length, 1); }); it('should pass through className', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null, /*#__PURE__*/React.createElement(Panel.Footer, { className: "bar" }, "Footer"), "Content")); assert.equal(wrapper.find('.lucid-Panel-Footer.bar').length, 1); }); it('should not render when not included', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(Panel, null, "Content")); assert.equal(wrapper.find('.lucid-Panel-footer').length, 0); }); }); }); describe('any other children', function () {}); });