Skip to content

Commit 09bbefc

Browse files
committed
Add counterReducer spec
1 parent ae8b06a commit 09bbefc

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { INCREMENT_COUNTER, DECREMENT_COUNTER } from './actionTypes'
2+
import counterReducer from './counterReducer'
3+
import { CounterActionTypes } from './types'
4+
5+
describe('features > counter > counterReducer', () => {
6+
it(`increments value, if ${INCREMENT_COUNTER} action is provided`, () => {
7+
const initialState = {
8+
value: 0,
9+
}
10+
11+
const expectedState = {
12+
value: 1,
13+
}
14+
15+
const action: CounterActionTypes = {
16+
type: INCREMENT_COUNTER,
17+
}
18+
19+
expect(counterReducer(initialState, action)).toEqual(expectedState)
20+
})
21+
22+
it(`increments value, if ${DECREMENT_COUNTER} action is provided`, () => {
23+
const initialState = {
24+
value: 0,
25+
}
26+
27+
const expectedState = {
28+
value: -1,
29+
}
30+
31+
const action: CounterActionTypes = {
32+
type: DECREMENT_COUNTER,
33+
}
34+
35+
expect(counterReducer(initialState, action)).toEqual(expectedState)
36+
})
37+
})

0 commit comments

Comments
 (0)