import React from 'react'; import {Message} from 'semantic-ui-react'; import FlashAlerts, {Alert} from 'packs/react-app/components/misc/flash_alerts'; describe('', () => { describe('constructor()', () => { it('sets initial state', () => { const wrapper = shallow(); expect(wrapper.state('visible')).toBeTruthy(); chaiExpect(wrapper).to.have.state('visible', true); }); }); describe('onDismiss()', () => { it('alters state', () => { const wrapper = shallow(); wrapper.instance().onDismiss(); chaiExpect(wrapper).to.have.state('visible', false); }); }); describe('render()', () => { describe('should be visible', () => { it('renders the alert', () => { const wrapper = mount(); expect(wrapper).toMatchSnapshot(); expect(wrapper.find(Message).length).toEqual(1); }); }); describe('should be hidden', () => { const wrapper = mount(); wrapper.setState({visible: false}); expect(wrapper).toMatchSnapshot(); expect(wrapper.find(Message).length).toEqual(0); }); }); }); describe('', () => { describe('render()', () => { it('renders child alerts', () => { const wrapper = mount( , ); expect(wrapper.find(Alert).length).toEqual(2); }); }); });