Skip to content
Myr

test: draft nested in new object

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

authored by aleclarson · committed by aleclarson · parent 3c7f374 · Browse files · 1 file+38 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+38 added−0 removed

  • tests:+38 added−0 removed

1 file+38 added−0 removed

modified:__tests__/base.js+38 added
380 unmodified lines
381 }382 })383 })384385 it("can nest a draft in a new object (no changes)", () => {386 const nextState = produce(387 baseState,388 s => {389 s.foo = {bar: s.anObject}390 delete s.anObject391 },392 listener393 )394 expect(nextState).not.toBe(baseState)395 expect(nextState.foo.bar).toBe(baseState.anObject)396 })397398 it("can nest a draft in a new object (with changes)", () => {399 const nextState = produce(400 baseState,401 s => {402 const obj = s.anObject403 delete s.anObject404405 obj.coffee = true // change406 obj.nested.yummy = true // add407 delete obj.nested.yummie // delete408409 s.foo = {bar: obj}410 },411 listener412 )413 expect(nextState).not.toBe(baseState)414 expect(nextState.foo.bar).not.toBe(baseState.anObject)415 expect(nextState.foo).toEqual({416 bar: {417 coffee: true,418 nested: {yummy: true}419 }420 })421 })422423 it("should allow setting to undefined a defined draft property", () => {424 const nextState = produce(425 baseState,426 s => {
1100 unmodified lines