Skip to content
Myr

type verification test

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

authored by Michel Weststrate · committed by Michel Weststrate · parent cc61e1e · Browse files · 1 file+24 added−9 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+24 added−9 removed

  • tests:+24 added−9 removed

1 file+24 added−9 removed

modified:__tests__/base.js+24 added-9 removed
52 unmodified lines
53 // structural sharing?54 expect(nextState.nested).toBe(baseState.nested)55 })5657 it("deep change bubbles up", () => {58 const nextState = immer(baseState, s => {59 s.anObject.nested.yummie = false57 if (58 ("should preserve type",59 () => {60 const nextState = immer(baseState, s => {61 expect(Array.isArray(s)).toBe(true)62 expect(s.protoType).toBe(Object)63 s.anArray.push(3)64 s.aProp = "hello world"65 expect(Array.isArray(s)).toBe(true)66 expect(s.protoType).toBe(Object)67 })68 expect(Array.isArray(nextState)).toBe(true)69 expect(nextState.protoType).toBe(Object)70 })71 )72 it("deep change bubbles up", () => {73 const nextState = immer(baseState, s => {74 s.anObject.nested.yummie = false75 })61 expect(nextState).not.toBe(baseState)62 expect(nextState.anObject).not.toBe(baseState.anObject)63 expect(baseState.anObject.nested.yummie).toBe(true)64 expect(nextState.anObject.nested.yummie).toBe(false)65 expect(nextState.anArray).toBe(baseState.anArray)66 })76 expect(nextState).not.toBe(baseState)77 expect(nextState.anObject).not.toBe(baseState.anObject)78 expect(baseState.anObject.nested.yummie).toBe(true)79 expect(nextState.anObject.nested.yummie).toBe(false)80 expect(nextState.anArray).toBe(baseState.anArray)81 })8283 it("can add props", () => {84 const nextState = immer(baseState, s => {85 s.anObject.cookie = {tasty: true}
262 unmodified lines