Skip to content
Myr

test: recursive produce call in async recipe

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

authored by aleclarson · committed by aleclarson · parent 5fee518 · Browse files · 1 file+25 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+25 added−0 removed

  • tests:+25 added−0 removed

1 file+25 added−0 removed

modified:__tests__/base.js+25 added
859 unmodified lines
860 expect(e).toBe(err)861 expect(() => draft.a).toThrowError(/revoked/)862 }863 })864865 it("supports recursive produce calls after await", async () => {866 const base = {obj: {k: 1}}867 const res = await produce(base, async d => {868 const obj = d.obj869 delete d.obj870871 // Force the recipe function to return.872 await Promise.resolve()873874 d.a = produce({}, d => {875 d.b = obj // Assign a draft owned by the parent scope.876 })877878 // Auto-freezing is prevented when an unowned draft exists.879 expect(Object.isFrozen(d.a)).toBeFalsy()880881 // Ensure `obj` is not revoked.882 obj.c = 1883 })884 expect(res).not.toBe(base)885 expect(res).toEqual({886 a: {b: {k: 1, c: 1}}887 })888 })889 })890891 it("throws when the draft is modified and another object is returned", () => {892 const base = {x: 3}
314 unmodified lines