Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function counter(state = 0){
- if(action.type === "INCREMENT"){
- return state +1
- } else if(action.type === "DECREMENT"){
- return state - 1
- } else {
- return state
- }
- }
- expect(
- counter(0, {type: "INCREMENT"})
- ).toEqual(1)
- expect(
- counter(1, {type: "INCREMENT"})
- ).toEqual(2)
- expect(
- counter(2, {type: "DECREMENT"})
- ).toEqual(1)
- expect(
- counter(2, {type: "DECREMENT"})
- ).toEqual(0)
- expect(
- counter(undefined, {})
- ).toEqual(0)
- console.log('test passed')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement