flash_alerts.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react';
  2. import {Message} from 'semantic-ui-react';
  3. import {Alert} from 'packs/react-app/components/misc/flash_alerts';
  4. describe('<Alert />', () => {
  5. describe('constructor()', () => {
  6. it('sets initial state', () => {
  7. const wrapper = shallow(<Alert />);
  8. expect(wrapper.state('visible')).toBeTruthy();
  9. chaiExpect(wrapper).to.have.state('visible', true);
  10. });
  11. });
  12. describe('onDismiss()', () => {
  13. it('alters state', () => {
  14. const wrapper = shallow(<Alert />);
  15. wrapper.instance().onDismiss();
  16. chaiExpect(wrapper).to.have.state('visible', false);
  17. });
  18. });
  19. describe('render()', () => {
  20. describe('should be visible', () => {
  21. it('renders the alert', () => {
  22. const wrapper = mount(<Alert klass="foo-alert" />);
  23. expect(wrapper).toMatchSnapshot();
  24. expect(wrapper.find(Message).length).toEqual(1);
  25. });
  26. });
  27. describe('should be hidden', () => {
  28. const wrapper = mount(<Alert klass="foo-alert" />);
  29. wrapper.setState({visible: false});
  30. expect(wrapper).toMatchSnapshot();
  31. expect(wrapper.find(Message).length).toEqual(0);
  32. });
  33. });
  34. });