Skip to content

Commit

Permalink
add reducers tests for undefined state
Browse files Browse the repository at this point in the history
  • Loading branch information
antonk52 committed May 2, 2021
1 parent 3e81a3a commit f21f5a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/immer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ describe('immer', () => {
expect(result).toEqual({id: 123, result: 'loading'})
});

it('accepts undefined as the state argument', () => {
const result = reducer(undefined, req.init(123));

expect(result).toEqual({id: 123, result: 'loading'})
});

it('modifies state as expected by returning', () => {
const st: State = {
...defaultState,
Expand Down
6 changes: 6 additions & 0 deletions test/reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ describe('reducer', () => {
expect(result).toEqual({id: 123, result: 'loading'})
});

it('accepts undefined as the state argument', () => {
const result = reducer(undefined, req.init(123));

expect(result).toEqual({id: 123, result: 'loading'})
});

it('does not modify state for unknown action', () => {
const st: State = {
...defaultState,
Expand Down

0 comments on commit f21f5a6

Please sign in to comment.