Adding Jest
This commit is contained in:
@@ -0,0 +1 @@
|
||||
module.exports = {};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = () => 'mock SVG';
|
||||
@@ -0,0 +1,29 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Message rendering 1`] = `
|
||||
<div
|
||||
className={undefined}
|
||||
>
|
||||
<h2>
|
||||
|
||||
Testing
|
||||
</h2>
|
||||
<p>
|
||||
Message content
|
||||
</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Message rendering with icon 1`] = `
|
||||
<div
|
||||
className={undefined}
|
||||
>
|
||||
<h2>
|
||||
Sample icon SVG
|
||||
Testing
|
||||
</h2>
|
||||
<p>
|
||||
Message content
|
||||
</p>
|
||||
</div>
|
||||
`;
|
||||
@@ -12,7 +12,10 @@ const Message = ({ icon, heading, children }) => {
|
||||
};
|
||||
|
||||
Message.propTypes = {
|
||||
icon: PropTypes.element,
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.element,
|
||||
PropTypes.func
|
||||
]),
|
||||
heading: PropTypes.string.isRequired,
|
||||
children: PropTypes.element.isRequired
|
||||
};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
import Message from './index';
|
||||
|
||||
test('Message rendering', () => {
|
||||
const component = renderer.create(
|
||||
<Message heading="Testing">
|
||||
<p>Message content</p>
|
||||
</Message>
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Message rendering with icon', () => {
|
||||
const Icon = () => 'Sample icon SVG';
|
||||
const component = renderer.create(
|
||||
<Message heading="Testing" icon={ Icon }>
|
||||
<p>Message content</p>
|
||||
</Message>
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
Reference in New Issue
Block a user