-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(testing): adds enzyme and updates exisiting tests
- Loading branch information
Showing
13 changed files
with
559 additions
and
133 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 87 additions & 1 deletion
88
src/components/AboutModal/__snapshots__/AboutModal.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,89 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AboutModal renders correctly when hidden 1`] = `null`; | ||
exports[`AboutModal renders correctly when hidden 1`] = ` | ||
<Modal | ||
animation={true} | ||
autoFocus={true} | ||
backdrop={true} | ||
bsClass="modal" | ||
className="" | ||
contentClassName="about-modal-pf" | ||
dialogComponentClass={[Function]} | ||
enforceFocus={true} | ||
keyboard={true} | ||
manager={ | ||
ModalManager { | ||
"add": [Function], | ||
"containers": Array [], | ||
"data": Array [], | ||
"handleContainerOverflow": true, | ||
"hideSiblingNodes": true, | ||
"isTopModal": [Function], | ||
"modals": Array [], | ||
"remove": [Function], | ||
} | ||
} | ||
onHide={[Function]} | ||
renderBackdrop={[Function]} | ||
restoreFocus={true} | ||
show={false} | ||
> | ||
<ModalHeader | ||
bsClass="modal-header" | ||
closeButton={false} | ||
closeLabel="Close" | ||
> | ||
<ModalCloseButton | ||
className="" | ||
closeText="Close" | ||
onClick={[Function]} | ||
/> | ||
</ModalHeader> | ||
<ModalBody | ||
bsClass="modal-body" | ||
componentClass="div" | ||
> | ||
<h1> | ||
Product Title | ||
</h1> | ||
<AboutModalVersions | ||
className="" | ||
> | ||
<AboutModalVersionItem | ||
className="" | ||
label="Label" | ||
versionText="Version" | ||
/> | ||
<AboutModalVersionItem | ||
className="" | ||
label="Label" | ||
versionText="Version" | ||
/> | ||
<AboutModalVersionItem | ||
className="" | ||
label="Label" | ||
versionText="Version" | ||
/> | ||
<AboutModalVersionItem | ||
className="" | ||
label="Label" | ||
versionText="Version" | ||
/> | ||
</AboutModalVersions> | ||
<div | ||
className="trademark-pf" | ||
> | ||
Trademark and Copyright Information | ||
</div> | ||
</ModalBody> | ||
<ModalFooter | ||
bsClass="modal-footer" | ||
componentClass="div" | ||
> | ||
<img | ||
alt="Patternfly Logo" | ||
src="" | ||
/> | ||
</ModalFooter> | ||
</Modal> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
/* eslint-env jest */ | ||
|
||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
|
||
import { shallow } from 'enzyme'; | ||
import Button from './Button'; | ||
|
||
test('Button renders properly', () => { | ||
const component = renderer.create( | ||
const component = shallow( | ||
<Button id="button1">Default button</Button> | ||
); | ||
).getElement(); | ||
|
||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
test('Button allows to specify size and style', () => { | ||
const component = renderer.create( | ||
const component = shallow( | ||
<Button id="button1" bsStyle="primary" bsSize="large"> | ||
Large Primary button | ||
</Button> | ||
); | ||
).getElement(); | ||
|
||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
expect(component).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
/* eslint-env jest */ | ||
|
||
import React from 'react'; | ||
import ShallowRenderer from 'react-test-renderer/shallow'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
/* eslint-env jest */ | ||
|
||
import React from 'react'; | ||
import ShallowRenderer from 'react-test-renderer/shallow'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import { BarChart, GroupedBarChart, StackedBarChart } from './index'; | ||
|
||
const renderer = new ShallowRenderer(); | ||
|
||
test('BarChart renders properly', () => { | ||
expect( | ||
renderer.render(<BarChart id="area-1" data={{ columns: [['data', 42]] }} />) | ||
shallow( | ||
<BarChart id="area-1" data={{ columns: [['data', 42]] }} /> | ||
).getElement() | ||
).toMatchSnapshot(); | ||
}); | ||
|
||
test('GroupedBarChart renders properly', () => { | ||
expect( | ||
renderer.render( | ||
shallow( | ||
<GroupedBarChart id="area-2" data={{ columns: [['data', 42]] }} /> | ||
) | ||
).getElement() | ||
).toMatchSnapshot(); | ||
}); | ||
|
||
test('StackedBarChart renders properly', () => { | ||
expect( | ||
renderer.render( | ||
shallow( | ||
<StackedBarChart id="area-3" data={{ columns: [['data', 42]] }} /> | ||
) | ||
).getElement() | ||
).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
/* eslint-env jest */ | ||
|
||
import React from 'react'; | ||
import ShallowRenderer from 'react-test-renderer/shallow'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import { DonutChart } from './index'; | ||
|
||
const renderer = new ShallowRenderer(); | ||
|
||
test('DonutChart renders properly', () => { | ||
expect( | ||
renderer.render( | ||
shallow( | ||
<DonutChart id="area-1" data={{ columns: [['data', 42]] }} /> | ||
) | ||
).getElement() | ||
).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,28 @@ | ||
/* eslint-env jest */ | ||
|
||
import React from 'react'; | ||
import ShallowRenderer from 'react-test-renderer/shallow'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import { LineChart, SingleLineChart, SparklineChart } from './index'; | ||
|
||
const renderer = new ShallowRenderer(); | ||
|
||
test('LineChart renders properly', () => { | ||
expect( | ||
renderer.render( | ||
shallow( | ||
<LineChart id="area-1" data={{ columns: [['data', 42]] }} /> | ||
) | ||
).getElement() | ||
).toMatchSnapshot(); | ||
}); | ||
|
||
test('SingleLineChart renders properly', () => { | ||
expect( | ||
renderer.render( | ||
shallow( | ||
<SingleLineChart id="area-2" data={{ columns: [['data', 42]] }} /> | ||
) | ||
).getElement() | ||
).toMatchSnapshot(); | ||
}); | ||
|
||
test('SparklineChart renders properly', () => { | ||
expect( | ||
renderer.render( | ||
shallow( | ||
<SparklineChart id="area-3" data={{ columns: [['data', 42]] }} /> | ||
) | ||
).getElement() | ||
).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
import 'raf/polyfill'; | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
configure({ adapter: new Adapter() }); |