Skip to content

Commit

Permalink
chore: Add failing test for nested and chained produce calls (#935)
Browse files Browse the repository at this point in the history
* Add failing test for nested and chained produce calls

* Update test to not reference same object twice
  • Loading branch information
jpallen committed Jan 15, 2023
1 parent 847b662 commit 04c5fb3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions __tests__/regressions.js
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: "banana"
}
}
}
const newState = produce(state, draft => {
draft.foo = produce(draft.foo, fooDraft => {
fooDraft.baz = fooDraft.bar.baz.replace("banana", "apple")
})
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 04c5fb3

Please sign in to comment.