@retailmenot/anchor
Version:
A React UI Library by RetailMeNot
40 lines • 2.57 kB
JavaScript
// VENDOR
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import { ThemeProvider } from '@xstyled/styled-components';
import { shallow, mount } from 'enzyme';
// ANCHOR
import { RootTheme } from '../../src/theme';
import { Alert } from './Alert.component';
import { Info, Check, Error } from '../Icon';
describe('Component: Alert', () => {
it('should be closable', () => {
const subject = (React.createElement(ThemeProvider, { theme: RootTheme },
React.createElement(Alert, { variant: "warning", title: "Test Title", description: "Test Description", closable: true })));
const wrapper = mount(subject);
expect(wrapper.find('div.anchor-alert')).toHaveLength(1);
wrapper.find('button.anchor-alert-close').simulate('click');
wrapper.update();
expect(wrapper.find('div.anchor-alert')).toHaveLength(0);
});
it('should match its snapshot.', () => {
const subject = (React.createElement(ThemeProvider, { theme: RootTheme },
React.createElement(React.Fragment, null,
React.createElement(Alert, { variant: "warning", title: "Test Title", description: "Test Description" }),
React.createElement(Alert, { variant: "warning", title: "Test Title", description: "Test Description", icon: React.createElement(Info, null) }),
React.createElement(Alert, { variant: "info", title: "Test Title", description: "Test Description" }),
React.createElement(Alert, { variant: "info", title: "Test Title", description: "Test Description", icon: React.createElement(Info, null) }),
React.createElement(Alert, { variant: "success", title: "Test Title", description: "Test Description" }),
React.createElement(Alert, { variant: "success", title: "Test Title", description: "Test Description", icon: React.createElement(Check, null) }),
React.createElement(Alert, { variant: "error", title: "Test Title", description: "Test Description" }),
React.createElement(Alert, { variant: "error", title: "Test Title", description: "Test Description", icon: React.createElement(Error, null) }))));
const wrapper = mount(subject);
const component = shallow(subject);
expect(subject).toBeDefined();
expect(wrapper).toBeDefined();
expect(component).toBeDefined();
const tree = renderer.create(subject).toJSON();
expect(tree).toMatchSnapshot();
});
});
//# sourceMappingURL=Alert.component.spec.js.map