Skip to content
Myr

Give warning if something is returned from thunk #3

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Gregory Assasie · committed by Gregory Assasie · parent 68f6fb5 · Browse files · 2 files+29 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+29 added−1 removed

  • tests:+11 added−0 removed
  • other:+18 added−1 removed

2 files+29 added−1 removed

modified:__tests__/base.js+11 added
19 unmodified lines
20 })21 expect(nextState).toBe(baseState)22 })2324 it("should not return any value: thunk", () => {25 const warning = jest.spyOn(console, "warn");2627 const nextState = immer(baseState, () => ({bad: "don't do this"}))28 const nextState1 = immer(baseState, () => [1,2,3])29 const nextState2 = immer(baseState, () => false)30 const nextState3 = immer(baseState, () => "")3132 expect(warning).toHaveBeenCalledTimes(4);33 })3435 it("should return a copy when modifying stuff", () => {36 const nextState = immer(baseState, s => {37 s.aProp = "hello world"38 })
206 unmodified lines
modified:immer.js+18 added-1 removed