Skip to content
Myr

test: more recursive produce tests

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

authored by Alec Larson · committed by Alec Larson · parent 9e12f56 · Browse files · 1 file+26 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+26 added−0 removed

  • tests:+26 added−0 removed

1 file+26 added−0 removed

modified:__tests__/base.js+26 added
626 unmodified lines
627 expect(original(child)).toBe(parent)628 })629 })630 })631632 // Reported by: https://github.com/mweststrate/immer/issues/343633 it("ensures each property is drafted", () => {634 produce({a: {}, b: {}}, parent => {635 parent.a // Access "a" but not "b"636 produce(parent, child => {637 child.c = 1638 expect(isDraft(child.a)).toBeTruthy()639 expect(isDraft(child.b)).toBeTruthy()640 })641 })642 })643644 it("preserves any pending changes", () => {645 produce({a: 1, b: 1, d: 1}, parent => {646 parent.b = 2647 parent.c = 2648 delete parent.d649 produce(parent, child => {650 expect(child.a).toBe(1) // unchanged651 expect(child.b).toBe(2) // changed652 expect(child.c).toBe(2) // added653 expect(child.d).toBeUndefined() // deleted654 })655 })656 })657 })658659 describe("when base state contains a draft", () => {660 it("wraps unowned draft with its own draft", () => {
609 unmodified lines