Skip to content
Myr

test: interweaved Immer instances

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

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

  • tests:+22 added−1 removed

1 file+22 added−1 removed

modified:__tests__/base.js+22 added-1 removed
1"use strict"2import {Immer, nothing, isDraft} from "../src/index"2import {Immer, nothing, original, isDraft} from "../src/index"3import {shallowCopy} from "../src/common"4import deepFreeze from "deep-freeze"5import cloneDeep from "lodash.clonedeep"6import * as lodash from "lodash"
796 unmodified lines
803 expect(produce({}, () => [parent.b])[0]).toBe(parent.b)804 parent.b.x // Ensure proxy not revoked.805 })806 })807808 it("works with interweaved Immer instances", () => {809 const options = {useProxies, autoFreeze}810 const one = new Immer(options)811 const two = new Immer(options)812813 const base = {}814 const result = one.produce(base, s1 =>815 two.produce({s1}, s2 => {816 expect(original(s2.s1)).toBe(s1)817 s2.n = 1818 s2.s1 = one.produce({s2}, s3 => {819 expect(original(s3.s2)).toBe(s2)820 expect(original(s3.s2.s1)).toBe(s2.s1)821 return s3.s2.s1822 })823 })824 )825 expect(result.n).toBe(1)826 expect(result.s1).toBe(base)827 })828 })829830 it("should not try to change immutable data, see #66", () => {831 const user = require("./test-data")
491 unmodified lines