Adding Jest

This commit is contained in:
Jeff Avallone
2018-02-10 18:30:07 -05:00
parent 916b38c6c5
commit 3e729b2a34
8 changed files with 923 additions and 40 deletions
+1
View File
@@ -0,0 +1 @@
module.exports = {};
+1
View File
@@ -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>
`;
+4 -1
View File
@@ -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
};
+25
View File
@@ -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();
});