Updating Message tests to use enzyme

This commit is contained in:
Jeff Avallone 2018-02-11 11:50:08 -05:00
parent cabc2adc1f
commit 637c9c2afd
2 changed files with 7 additions and 10 deletions

View File

@ -1,25 +1,23 @@
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer'; import { shallow, render } from 'enzyme';
import Message from './Message'; import Message from './Message';
test('Message rendering', () => { test('Message rendering', () => {
const component = renderer.create( const component = shallow(
<Message heading="Testing"> <Message heading="Testing">
<p>Message content</p> <p>Message content</p>
</Message> </Message>
); );
let tree = component.toJSON(); expect(component).toMatchSnapshot();
expect(tree).toMatchSnapshot();
}); });
test('Message rendering with icon', () => { test('Message rendering with icon', () => {
const Icon = () => 'Sample icon SVG'; const Icon = () => 'Sample icon SVG';
const component = renderer.create( const component = render(
<Message heading="Testing" icon={ Icon }> <Message heading="Testing" icon={ Icon }>
<p>Message content</p> <p>Message content</p>
</Message> </Message>
); );
let tree = component.toJSON(); expect(component).toMatchSnapshot();
expect(tree).toMatchSnapshot();
}); });

View File

@ -15,11 +15,10 @@ exports[`Message rendering 1`] = `
exports[`Message rendering with icon 1`] = ` exports[`Message rendering with icon 1`] = `
<div <div
className="message" class="message"
> >
<h2> <h2>
Sample icon SVG Sample icon SVGTesting
Testing
</h2> </h2>
<p> <p>
Message content Message content