Skip to content
Myr

test: delete then set an existing property

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 37f57f0 · 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
108 unmodified lines
109 expect(nextState).toBe(baseState)110 }111 })112113 // Found by: https://github.com/mweststrate/immer/issues/328114 it("can set a property that was just deleted", () => {115 const baseState = {a: 1}116 const nextState = produce(baseState, s => {117 delete s.a118 s.a = 2119 })120 expect(nextState.a).toBe(2)121 })122123 it("can set a property to its original value after deleting it", () => {124 const baseState = {a: {b: 1}}125 const nextState = produce(baseState, s => {126 const a = s.a127 delete s.a128 s.a = a129 })130 if (useProxies) {131 expect(nextState).not.toBe(baseState)132 expect(nextState).toEqual(baseState)133 } else {134 // The copy is avoided in ES5.135 expect(nextState).toBe(baseState)136 }137 })138139 it("can get property descriptors", () => {140 const getDescriptor = Object.getOwnPropertyDescriptor141 const baseState = deepFreeze([{a: 1}])142 produce(baseState, arr => {
1101 unmodified lines