Skip to content
Myr

chore: Add failing test for nested and chained produce calls (#935)

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

* Add failing test for nested and chained produce calls * Update test to not reference same object twice

authored by James Allen · committed by GitHub · parent 847b662 · Browse files · 1 file+20 added−0 removed
This commit

State

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

Diff stats

1 file+20 added−0 removed

  • tests:+20 added−0 removed

1 file+20 added−0 removed

modified:__tests__/regressions.js+20 added
249 unmodified lines
250 expect(newState).toEqual({251 baz: undefined252 })253 })254255 test("Nested and chained produce calls throw 'Cannot perform 'get' on a proxy that has been revoked' error", () => {256 const state = {257 foo: {258 bar: {259 baz: "banana"260 }261 }262 }263 const newState = produce(state, draft => {264 draft.foo = produce(draft.foo, fooDraft => {265 fooDraft.baz = fooDraft.bar.baz.replace("banana", "apple")266 })267 draft.foo = produce(draft.foo, fooDraft => {268 /* another produce call makes this fail */269 /* no actual mutation necessary to make this happen */270 })271 })272 JSON.stringify(newState)273 })274 })275}