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deepCopy', () => {\n test('should be able to preserve getters', () => {\n expect.assertions(1)\n const original = {\n value: 0,\n get valuePlusTwo() {\n return this.value + 2\n },\n }\n const copy = deepCopy(original)\n copy.value = 15\n expect(copy.valuePlusTwo).toBe(17)\n })\n})\n\ndescribe('getChangeMutations', () => {\n test('should be able to create a set mutation when value has changed', () => {\n const stateA = {\n foo: 'bar',\n }\n const stateB = {\n foo: 'bar2',\n }\n const mutations = getChangeMutations(stateA, stateB)\n expect(mutations[0].path).toBe('foo')\n expect(mutations[0].args[0]).toBe('bar2')\n })\n test('should be able to create a set mutation when nested value has changed', () => {\n const stateA = {\n foo: {\n bar: {\n baz: 'mip',\n },\n },\n }\n const stateB = {\n foo: {\n bar: {\n baz: 'mip2',\n },\n },\n }\n const mutations = getChangeMutations(stateA, stateB)\n expect(mutations.length).toBe(1)\n expect(mutations[0].path).toBe('foo.bar.baz')\n expect(mutations[0].args[0]).toBe('mip2')\n })\n test('should be able to create an unset mutation when key is not there anymore', () => {\n const stateA = {\n foo: {\n bar: {\n baz: 'mip',\n },\n },\n }\n const stateB = {\n foo: {\n bar: {},\n },\n }\n const mutations = getChangeMutations(stateA, stateB)\n expect(mutations.length).toBe(1)\n expect(mutations[0].path).toBe('foo.bar.baz')\n expect(mutations[0].method).toBe('unset')\n })\n})\n"]}