1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

Add a few snapshot tests

This commit is contained in:
ivaosthu 2017-11-29 09:25:32 +01:00
parent a33aed3461
commit ff8b11af4d
5 changed files with 98 additions and 20 deletions

View File

@ -1,20 +1,22 @@
module.exports = {
Card: 'react-mdl-Card',
CardTitle: 'react-mdl-CardTitle',
CardText: 'react-mdl-CardText',
CardMenu: 'react-mdl-CardMenu',
DataTable: 'react-mdl-DataTable',
Cell: 'react-mdl-Cell',
Grid: 'react-mdl-Grid',
Icon: 'react-mdl-Icon',
IconButton: 'react-mdl-IconButton',
List: 'react-mdl-List',
ListItem: 'react-mdl-ListItem',
ListItemContent: 'react-mdl-ListItemContent',
ProgressBar: 'react-mdl-ProgressBar',
Switch: 'react-mdl-Switch',
Tab: 'react-mdl-Tab',
Tabs: 'react-mdl-Tabs',
TableHeader: 'react-mdl-TableHeader',
Textfield: 'react-mdl-Textfield',
Card: "react-mdl-Card",
CardTitle: "react-mdl-CardTitle",
CardText: "react-mdl-CardText",
CardMenu: "react-mdl-CardMenu",
DataTable: "react-mdl-DataTable",
Cell: "react-mdl-Cell",
Grid: "react-mdl-Grid",
Icon: "react-mdl-Icon",
IconButton: "react-mdl-IconButton",
List: "react-mdl-List",
ListItem: "react-mdl-ListItem",
ListItemContent: "react-mdl-ListItemContent",
ProgressBar: "react-mdl-ProgressBar",
Switch: "react-mdl-Switch",
Tab: "react-mdl-Tab",
Tabs: "react-mdl-Tabs",
TableHeader: "react-mdl-TableHeader",
Textfield: "react-mdl-Textfield",
FooterSection: "react-mdl-FooterSection",
FooterLinkList: "react-mdl-FooterLinkList"
};

View File

@ -0,0 +1,5 @@
{
"env": {
"jest": true
}
}

View File

@ -0,0 +1,51 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders correctly with details 1`] = `
<react-mdl-FooterSection
logo="Unleash 1.1.0"
type="bottom"
>
<react-mdl-FooterLinkList>
<a
href="https://github.com/Unleash/unleash/"
target="_blank"
>
GitHub
</a>
<a
href="https://www.finn.no"
target="_blank"
>
<small>
A product by
</small>
FINN.no
</a>
</react-mdl-FooterLinkList>
</react-mdl-FooterSection>
`;
exports[`renders correctly with empty api details 1`] = `
<react-mdl-FooterSection
logo="Unleash "
type="bottom"
>
<react-mdl-FooterLinkList>
<a
href="https://github.com/Unleash/unleash/"
target="_blank"
>
GitHub
</a>
<a
href="https://www.finn.no"
target="_blank"
>
<small>
A product by
</small>
FINN.no
</a>
</react-mdl-FooterLinkList>
</react-mdl-FooterSection>
`;

View File

@ -0,0 +1,18 @@
import React from 'react';
import ShowApiDetailsComponent from '../show-api-details-component';
import renderer from 'react-test-renderer';
jest.mock('react-mdl');
test('renders correctly with empty api details', () => {
const tree = renderer.create(<ShowApiDetailsComponent fetchAll={jest.fn()} apiDetails={{}} />).toJSON();
expect(tree).toMatchSnapshot();
});
test('renders correctly with details', () => {
const tree = renderer
.create(<ShowApiDetailsComponent fetchAll={jest.fn()} apiDetails={{ version: '1.1.0' }} />)
.toJSON();
expect(tree).toMatchSnapshot();
});

View File

@ -1,8 +1,8 @@
import React from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FooterSection, FooterLinkList } from 'react-mdl';
export default class ShowApiDetailsComponent extends React.Component {
class ShowApiDetailsComponent extends Component {
static propTypes = {
apiDetails: PropTypes.object.isRequired,
fetchAll: PropTypes.func.isRequired,
@ -28,3 +28,5 @@ export default class ShowApiDetailsComponent extends React.Component {
);
}
}
export default ShowApiDetailsComponent;