Skip to content

Commit

Permalink
fix test bug after using CSS modules.
Browse files Browse the repository at this point in the history
And for the devDependencies issue, I just found this:
facebook/create-react-app#2696
the conclusion is CRA remove devDependencies on purpose.
  • Loading branch information
ym-guotao committed Dec 1, 2017
1 parent 02ab7a0 commit c7bf7ab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"flow-bin": "^0.59.0"
},
"jest": {
"globals": {
"window": true
},
"collectCoverageFrom": [
"src/**/*.{js,jsx}",
"!src/registerServiceWorker.js",
Expand Down
4 changes: 2 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ class App extends Component {
<Card
className={
this.state.showJSON
? style.json_card
: `${style.json_card} ${style.hide}`
? `${style.json_card} result`
: `${style.json_card} ${style.hide} result`
}
>
<CardBody>
Expand Down
15 changes: 8 additions & 7 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import React from 'react'
import { mount } from 'enzyme'
import { Provider } from 'react-redux'

Expand All @@ -18,14 +18,15 @@ const subject = (
<App />
</Provider>
)
const wrapper = mount(subject)

it('renders without crashing', () => {
mount(subject)
})

const wrapper = mount(subject)
it('should insert a stringify JSON to page', () => {
store.dispatch(onFieldChange(exampleJSON))
it('renders without crashing', () => {
wrapper
})
expect(wrapper.find('.json-card .card-text').text()).toEqual(
expect(wrapper.find('.result .card-text').text()).toEqual(
JSON.stringify(exampleJSON)
)
})
Expand All @@ -47,7 +48,7 @@ const exampleJSON2 = {

it('should save state to store when click submit', () => {
store.dispatch(accountFormSubmit(exampleJSON2))
expect(wrapper.find('.json-card .card-text').text()).toEqual(
expect(wrapper.find('.result .card-text').text()).toEqual(
JSON.stringify(exampleJSON2)
)
})

0 comments on commit c7bf7ab

Please sign in to comment.