Skip to content

Commit

Permalink
Add failing test for nested and chained produce calls
Browse files Browse the repository at this point in the history
  • Loading branch information
James Allen committed May 10, 2022
1 parent 285fff9 commit 18809a6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions __tests__/regressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,25 @@ function runBaseTest(name, useProxies, autoFreeze, useListener) {
baz: undefined
})
})

test("Nested and chained produce calls throw 'Cannot perform 'get' on a proxy that has been revoked' error", () => {
const state = {
foo: {
bar: {
baz: 1
}
}
}
const newState = produce(state, draft => {
draft.foo = produce(draft.foo, fooDraft => {
fooDraft.baz = fooDraft.bar.baz
})
draft.foo = produce(draft.foo, fooDraft => {
/* another produce call makes this fail */
/* no actual mutation necessary to make this happen */
})
})
JSON.stringify(newState)
})
})
}

0 comments on commit 18809a6

Please sign in to comment.