UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

86 lines 3.88 kB
import React from 'react'; import { shallow } from 'enzyme'; import assert from 'assert'; import { common } from '../../util/generic-tests'; import LoadingMessage from './LoadingMessage'; import LoadingIcon from '../Icon/LoadingIcon/LoadingIcon'; import SuccessIcon from '../Icon/SuccessIcon/SuccessIcon'; var Icon = LoadingMessage.Icon, Title = LoadingMessage.Title, Body = LoadingMessage.Body; describe('LoadingMessage', function () { common(LoadingMessage); describe('render', function () { var wrapper; beforeEach(function () { return wrapper = shallow( /*#__PURE__*/React.createElement(LoadingMessage, null)); }); it('should render a LoadingIcon', function () { assert.equal(wrapper.find(LoadingIcon).length, 1, 'must render loading icon'); }); it('should render "Loading" as the title', function () { assert.equal(wrapper.find('.lucid-LoadingMessage-title').text(), 'Loading'); }); it('should not render a body', function () { assert.equal(wrapper.find('.lucid-LoadingMessage-body').length, 0); }); it('should not have `&-no-content` class', function () { assert(!wrapper.hasClass('lucid-LoadingMessage-no-content')); }); }); describe('child components', function () { describe('Icon', function () { it('should render the custom icon', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(LoadingMessage, null, /*#__PURE__*/React.createElement(Icon, null, /*#__PURE__*/React.createElement(SuccessIcon, null)))); assert.equal(wrapper.find(SuccessIcon).length, 1); }); it('should render the custom icon', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(LoadingMessage, { Icon: /*#__PURE__*/React.createElement(SuccessIcon, null) })); assert.equal(wrapper.find(SuccessIcon).length, 1); }); }); describe('Title', function () { it('should render the custom title', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(LoadingMessage, null, /*#__PURE__*/React.createElement(Title, null, "A custom title"))); assert.equal(wrapper.find('.lucid-LoadingMessage-title').text(), 'A custom title'); }); it('should render the custom title', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(LoadingMessage, { Title: "A custom title" })); assert.equal(wrapper.find('.lucid-LoadingMessage-title').text(), 'A custom title'); }); describe('null', function () { var wrapper; beforeEach(function () { return wrapper = shallow( /*#__PURE__*/React.createElement(LoadingMessage, { Title: null })); }); it('should render a LoadingIcon', function () { assert.equal(wrapper.find(LoadingIcon).length, 1, 'must render loading icon'); }); it('should not render a title', function () { assert.equal(wrapper.find('.lucid-LoadingMessage-title').length, 0); }); it('should add `&-no-content` class', function () { assert(wrapper.hasClass('lucid-LoadingMessage-no-content')); }); }); }); describe('Body', function () { it('should render the custom body', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(LoadingMessage, null, /*#__PURE__*/React.createElement(Body, null, "A custom body"))); assert.equal(wrapper.find('.lucid-LoadingMessage-body').text(), 'A custom body'); }); it('should render the custom body', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(LoadingMessage, { Body: "A custom body" })); assert.equal(wrapper.find('.lucid-LoadingMessage-body').text(), 'A custom body'); }); }); }); });