import React from 'react'; import { shallow } from 'enzyme'; import assert from 'assert'; import { common } from '../../util/generic-tests'; import OverlayWrapper from './OverlayWrapper'; import { CSSTransition } from 'react-transition-group'; const { Message } = OverlayWrapper; describe('OverlayWrapper', () => { common(OverlayWrapper); describe('isVisible', () => { describe('default', () => { let wrapper: any; beforeEach(() => { wrapper = shallow(
Some content
); }); it('should render CSSTransition with correct in prop', () => { assert.equal(wrapper.find(CSSTransition).props().in, false); }); it('should render other content', () => { assert(wrapper.contains(
Some content
)); }); }); describe('false', () => { let wrapper: any; beforeEach(() => { wrapper = shallow(
Some content
); }); it('should render CSSTransition with correct in prop', () => { assert.equal(wrapper.find(CSSTransition).props().in, false); }); it('should render other content', () => { assert(wrapper.contains(
Some content
)); }); }); describe('true', () => { let wrapper: any; beforeEach(() => { wrapper = shallow( Danger!
Some content
); }); it('should render CSSTransition with correct in prop', () => { assert.equal(wrapper.find(CSSTransition).props().in, true); }); it('should show the overlay message', () => { assert.equal( wrapper.find('.lucid-OverlayWrapper-message-container').length, 1 ); assert.equal(wrapper.find('.overlay-message').length, 1); }); it('should render other content', () => { assert(wrapper.contains(
Some content
)); }); }); }); describe('hasOverlay', () => { describe('default', () => { it('should add `&-has-overlay` class', () => { const wrapper = shallow(
Some content
); const messageContainer = wrapper.find( '.lucid-OverlayWrapper-message-container' ); assert(messageContainer.hasClass('lucid-OverlayWrapper-has-overlay')); }); }); describe('true', () => { it('should add `&-has-overlay` class', () => { const wrapper = shallow(
Some content
); const messageContainer = wrapper.find( '.lucid-OverlayWrapper-message-container' ); assert(messageContainer.hasClass('lucid-OverlayWrapper-has-overlay')); }); }); describe('false', () => { it('should not add `&-has-overlay` class', () => { const wrapper = shallow(
Some content
); const messageContainer = wrapper.find( '.lucid-OverlayWrapper-message-container' ); assert(!messageContainer.hasClass('lucid-OverlayWrapper-has-overlay')); }); }); }); describe('anchorMessage', () => { describe('default', () => { it('should not add `&-anchored-message` class', () => { const wrapper = shallow(
Some content
); const messageContainer = wrapper.find( '.lucid-OverlayWrapper-message-container' ); assert( !messageContainer.hasClass('lucid-OverlayWrapper-anchored-message') ); }); }); describe('true', () => { it('should add `&-anchored-message` class', () => { const wrapper = shallow(
Some content
); const messageContainer = wrapper.find( '.lucid-OverlayWrapper-message-container' ); assert( messageContainer.hasClass('lucid-OverlayWrapper-anchored-message') ); }); }); describe('false', () => { it('should not add `&-anchored-message` class', () => { const wrapper = shallow(
Some content
); const messageContainer = wrapper.find( '.lucid-OverlayWrapper-message-container' ); assert( !messageContainer.hasClass('lucid-OverlayWrapper-anchored-message') ); }); }); }); describe('overlayKind', () => { describe('light', () => { it('should add `&-kind-light` class', () => { const wrapper = shallow(
Some content
); const messageContainer = wrapper.find( '.lucid-OverlayWrapper-message-container' ); assert(messageContainer.hasClass('lucid-OverlayWrapper-kind-light')); }); }); }); });