Skip to content

Commit

Permalink
add test for setState with replace
Browse files Browse the repository at this point in the history
  • Loading branch information
devanshj committed Apr 11, 2022
1 parent abf876a commit 061a057
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/types.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,16 @@ it('should allow for different partial keys to be returnable from setState', ()
return { something: true }
})
})

it('setState with replace requires whole state', () => {
const store = create<{ count: number; something: string }>(() => ({
count: 0,
something: 'foo',
}))

store.setState(
// @ts-expect-error missing `something`
{ count: 1 },
true
)
})

0 comments on commit 061a057

Please sign in to comment.