@retailmenot/anchor
Version:
A React UI Library by RetailMeNot
36 lines • 1.59 kB
JavaScript
// VENDOR
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import { mount } from 'enzyme';
import { ThemeProvider } from '@xstyled/styled-components';
// ANCHOR
import { RootTheme } from '../theme';
import { Card } from './Card.component';
// TEST SETUP
const testContent = 'Test';
const subject = (React.createElement(ThemeProvider, { theme: RootTheme },
React.createElement(Card, null,
React.createElement("p", null, testContent))));
describe('Component: Card', () => {
it('should match its snapshot.', () => {
const tree = renderer.create(subject).toJSON();
expect(tree).toMatchSnapshot();
});
it('should render the CardAction component when an action is provided', () => {
const testAction = 'Test Action';
const testSubject = (React.createElement(ThemeProvider, { theme: RootTheme },
React.createElement(Card, { action: React.createElement("p", null, testAction) })));
expect(mount(testSubject)
.find('div.anchor-card-action')
.text()).toBe(testAction);
});
it('should render the CardActionArea component when one is provided', () => {
const testAction = 'Test Action';
const testSubject = (React.createElement(ThemeProvider, { theme: RootTheme },
React.createElement(Card, { actionArea: React.createElement("p", null, testAction) })));
expect(mount(testSubject)
.find('div.anchor-card-action-area')
.text()).toBe(testAction);
});
});
//# sourceMappingURL=Card.component.spec.js.map