UNPKG

@retailmenot/anchor

Version:

A React UI Library by RetailMeNot

50 lines 2.19 kB
// REACT import * as React from 'react'; import * as renderer from 'react-test-renderer'; // VENDOR import { shallow, mount } from 'enzyme'; import { ThemeProvider } from '@xstyled/styled-components'; // ANCHOR import { Button, Typography } from '..'; // COMPONENT import { Hero } from './Hero.component'; import { RootTheme } from '../theme'; const { Title, Subtitle } = Hero; describe('Component: Hero', () => { it('should be defined', () => { const subject = (React.createElement(ThemeProvider, { theme: RootTheme }, React.createElement(Hero, 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(); }); it('should render with title', () => { const subject = (React.createElement(ThemeProvider, { theme: RootTheme }, React.createElement(Hero, null, React.createElement(Title, null, "Hero Title")))); const tree = renderer.create(subject).toJSON(); expect(tree).toMatchSnapshot(); }); it('should render with title and subtitle', () => { const subject = (React.createElement(ThemeProvider, { theme: RootTheme }, React.createElement(Hero, null, React.createElement(Title, null, "Hero Title"), React.createElement(Subtitle, null, "Hero Subtitle")))); const tree = renderer.create(subject).toJSON(); expect(tree).toMatchSnapshot(); }); it('should render with custom content', () => { const subject = (React.createElement(ThemeProvider, { theme: RootTheme }, React.createElement(Hero, null, React.createElement(Title, null, "Good Ole Title"), React.createElement(Typography, null, "Some Typography text"), React.createElement(Button, null, "CTA")))); const tree = renderer.create(subject).toJSON(); expect(tree).toMatchSnapshot(); }); }); //# sourceMappingURL=Hero.component.spec.js.map