This repository was archived by the owner on Mar 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Tests framework added #98
Merged
+307
−9
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
53c08ae
added enzyme and babel-jest
b4f14f1
Merge branch 'master' into tests
e1242a4
added all the revelant libs
fd7a273
added a sample test for common-banner component
a415158
removed redundant presets
1c1313f
Merge branch 'master' into tests
a3c887e
Merge branch 'master' into tests
8f03ed6
removed babel/jest
883ffc2
Merge branch 'tests' of github.com:coderplex/coderplex into tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Testing CommonBanner of \`components/common-banner\` Check the snapshot 1`] = ` | ||
<div | ||
className="jsx-1924801089" | ||
> | ||
<div | ||
className="jsx-1924801089 root" | ||
> | ||
<h1 | ||
className="jsx-1924801089 headline" | ||
/> | ||
<h2 | ||
className="jsx-1924801089" | ||
/> | ||
</div> | ||
<JSXStyle | ||
css=".root.jsx-1924801089{background-color:#f4f7fb;min-height:150px;text-align:center;padding-top:30px;padding-bottom:30px;}.headline.jsx-1924801089{font-size:4em;color:#df1cb5;font-weight:900;}h2.jsx-1924801089{max-width:1024px;margin-left:auto;margin-right:auto;-webkit-letter-spacing:2px;-moz-letter-spacing:2px;-ms-letter-spacing:2px;letter-spacing:2px;line-height:2;}@media (max-width:720px){h2.jsx-1924801089{font-size:14px;padding:0 10px;}}" | ||
styleId="1924801089" | ||
/> | ||
</div> | ||
`; |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import CommonBanner from '../components/common-banner'; | ||
|
||
describe('Testing CommonBanner of `components/common-banner`', () => { | ||
const shallowWrapper = shallow(<CommonBanner />); | ||
|
||
it('Check the snapshot', () => { | ||
expect(shallowWrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('should have title tag rendered', () => { | ||
expect(shallowWrapper.find('h1').length).toBe(1); | ||
}); | ||
|
||
it('should have subtitle tag rendered', () => { | ||
expect(shallowWrapper.find('h2').length).toBe(1); | ||
}); | ||
|
||
describe('should render the props', () => { | ||
const pageTitle = 'title of the page'; | ||
const pageSubTitle = 'Subtitle of the page'; | ||
const rootWrapper = shallow( | ||
<CommonBanner pageTitle={pageTitle} pageSubTitle={pageSubTitle} />, | ||
); | ||
|
||
it('should display title', () => { | ||
const headerElement = rootWrapper.find('.headline'); | ||
expect(headerElement.props().children).toEqual(pageTitle); | ||
}); | ||
|
||
it('should display subtitle', () => { | ||
const subHeaderElement = rootWrapper.find('h2'); | ||
expect(subHeaderElement.props().children).toEqual(pageSubTitle); | ||
}); | ||
}); | ||
}); |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
verbose: true, | ||
setupFiles: ['./jest.setup.js'], | ||
snapshotSerializers: ['enzyme-to-json/serializer'], | ||
}; |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint import/no-unassigned-import:0 */ | ||
import 'raf/polyfill'; | ||
|
||
import Enzyme from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need
babel-jest
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed!