Skip to content

Commit

Permalink
Merge pull request #32 from AlaeddineMessadi/add-counter-slice-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Apr 5, 2021
2 parents 90afb9d + a333e0b commit 6c8ba9c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions template/src/features/counter/counterSlice.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import counter from './counterSlice'

describe('counter reducer', () => {
it('should handle initial state', () => {
expect(counter(undefined, {})).toEqual({value: 0})
})


it('should handle increment', () => {
expect(
counter({ value: 3 }, {
type: 'counter/increment',
})
).toEqual({ value: 4 });
});


it('should handle decrement', () => {
expect(
counter({ value: 4 }, {
type: 'counter/decrement',
})
).toEqual({ value: 3 });
});


it('should handle incrementByAmount', () => {
expect(
counter({ value: 10 }, {
type: 'counter/incrementByAmount',
payload: 2
})
).toEqual({ value: 12 });
});
})

0 comments on commit 6c8ba9c

Please sign in to comment.