Merge pull request #2212 from MatthewShao/jest-dev

[web] Update Jest config and coverage ++
This commit is contained in:
Maximilian Hils 2017-03-27 17:04:13 +02:00 committed by GitHub
commit 9c686ca14c
3 changed files with 35 additions and 2 deletions

View File

@ -52,8 +52,10 @@ matrix:
before_install: before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash - curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH - export PATH=$HOME/.yarn/bin:$PATH
install: cd web && yarn install:
script: npm test - cd web && yarn
- yarn global add codecov
script: npm test && codecov
cache: cache:
yarn: true yarn: true
directories: directories:

View File

@ -13,6 +13,11 @@
], ],
"unmockedModulePathPatterns": [ "unmockedModulePathPatterns": [
"react" "react"
],
"coverageDirectory":"./coverage",
"collectCoverage": true,
"coveragePathIgnorePatterns": [
"<rootDir>/src/js/filt/filt.js"
] ]
}, },
"dependencies": { "dependencies": {

View File

@ -0,0 +1,26 @@
jest.unmock('../../ducks/settings')
jest.mock('../../utils')
import reduceSettings, * as SettingsActions from '../../ducks/settings'
describe('setting reducer', () => {
it('should return initial state', () => {
expect(reduceSettings(undefined, {})).toEqual({})
})
it('should handle receive action', () => {
let action = { type: SettingsActions.RECEIVE, data: 'foo' }
expect(reduceSettings(undefined, action)).toEqual('foo')
})
it('should handle update action', () => {
let action = {type: SettingsActions.UPDATE, data: {id: 1} }
expect(reduceSettings(undefined, action)).toEqual({id: 1})
})
})
describe('setting actions', () => {
it('should be possible to update setting', () => {
expect(reduceSettings(undefined, SettingsActions.update())).toEqual({})
})
})