-
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 existing tests
- Loading branch information
Showing
50 changed files
with
3,534 additions
and
5,905 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,34 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import { noop } from '../../common/helpers'; | ||
import { mount } from 'enzyme'; | ||
import { | ||
AboutModal, | ||
AboutModalVersions, | ||
AboutModalVersionItem | ||
} from '../../index'; | ||
|
||
test('AboutModal renders correctly when hidden', () => { | ||
const component = renderer.create( | ||
<AboutModal | ||
show={false} | ||
onHide={noop} | ||
productTitle="Product Title" | ||
altLogo="Patternfly Logo" | ||
trademarkText="Trademark and Copyright Information" | ||
> | ||
<AboutModalVersions> | ||
<AboutModalVersionItem label="Label" versionText="Version" /> | ||
<AboutModalVersionItem label="Label" versionText="Version" /> | ||
<AboutModalVersionItem label="Label" versionText="Version" /> | ||
<AboutModalVersionItem label="Label" versionText="Version" /> | ||
</AboutModalVersions> | ||
</AboutModal> | ||
); | ||
const testAboutModal = props => ( | ||
<AboutModal | ||
show={false} | ||
onHide={jest.fn()} | ||
productTitle="Product Title" | ||
altLogo="Patternfly Logo" | ||
trademarkText="Trademark and Copyright Information" | ||
{...props} | ||
> | ||
<AboutModalVersions> | ||
<AboutModalVersionItem label="Label" versionText="Version" /> | ||
</AboutModalVersions> | ||
</AboutModal> | ||
); | ||
|
||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
test('AboutModal renders correctly when hidden', () => { | ||
const component = mount(testAboutModal()); | ||
expect(component.render()).toMatchSnapshot(); | ||
expect(component.props().show).toBeFalsy(); | ||
}); | ||
|
||
/** TODO: requires https://github.com/react-bootstrap/react-overlays/issues/225 | ||
test('AboutModal renders correctly when shown', () => { | ||
const component = renderer.create( | ||
<AboutModal | ||
show | ||
onHide={noop} | ||
productTitle="Product Title" | ||
altLogo="Patternfly Logo" | ||
trademarkText="Trademark and Copyright Information" | ||
> | ||
<AboutModalVersions> | ||
<AboutModalVersionItem label="Label" versionText="Version" /> | ||
<AboutModalVersionItem label="Label" versionText="Version" /> | ||
<AboutModalVersionItem label="Label" versionText="Version" /> | ||
<AboutModalVersionItem label="Label" versionText="Version" /> | ||
</AboutModalVersions> | ||
</AboutModal> | ||
); | ||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
const component = mount(testAboutModal({ show: true })); | ||
expect(component.render()).toMatchSnapshot(); | ||
expect(component.props().show).toBeTruthy(); | ||
}); | ||
*/ |
80 changes: 80 additions & 0 deletions
80
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,83 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AboutModal renders correctly when hidden 1`] = `null`; | ||
|
||
exports[`AboutModal renders correctly when shown 1`] = ` | ||
<div | ||
role="dialog" | ||
> | ||
<div | ||
class="modal-backdrop fade in" | ||
/> | ||
<div | ||
class="fade in modal" | ||
role="dialog" | ||
style="display: block; padding-right: 0px;" | ||
tabindex="-1" | ||
> | ||
<div | ||
class="modal-dialog" | ||
> | ||
<div | ||
class="modal-content about-modal-pf" | ||
role="document" | ||
> | ||
<div | ||
class="modal-header" | ||
> | ||
<button | ||
class="close" | ||
> | ||
<span | ||
aria-hidden="true" | ||
class="pficon pficon-close" | ||
title="Close" | ||
/> | ||
<span | ||
class="sr-only" | ||
> | ||
Close | ||
</span> | ||
</button> | ||
</div> | ||
<div | ||
class="modal-body" | ||
> | ||
<h1> | ||
Product Title | ||
</h1> | ||
<div | ||
class="product-versions-pf" | ||
> | ||
<ul | ||
class="list-unstyled" | ||
> | ||
<li | ||
class="" | ||
> | ||
<strong> | ||
Label | ||
</strong> | ||
Version | ||
</li> | ||
</ul> | ||
</div> | ||
<div | ||
class="trademark-pf" | ||
> | ||
Trademark and Copyright Information | ||
</div> | ||
</div> | ||
<div | ||
class="modal-footer" | ||
> | ||
<img | ||
alt="Patternfly Logo" | ||
src="" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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
Oops, something went wrong.