original.js
This file
Path
__tests__/original.js
49 lines · 1.5 KiB · JavaScript
Last changed by
chore: update import paths in testsaleclarsonbefore adoptioncdc09b1
History of this fileTake it
The walk stopped after 200 commits: lines older than 51648ef point at it.
Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef
line 1why, one step back1"use strict"chore: update import paths in testsaleclarsonbefore adoptioncdc09b1
line 2why, one step back2import produce, {original, setUseProxies} from "../src/index"Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef
lines 3–49why, one step back34describe("original", () => {5 const baseState = {6 a: [],7 b: {}8 }910 it("should return the original from the draft", () => {11 setUseProxies(true)1213 produce(baseState, draftState => {14 expect(original(draftState)).toBe(baseState)15 expect(original(draftState.a)).toBe(baseState.a)16 expect(original(draftState.b)).toBe(baseState.b)17 })1819 setUseProxies(false)2021 produce(baseState, draftState => {22 expect(original(draftState)).toBe(baseState)23 expect(original(draftState.a)).toBe(baseState.a)24 expect(original(draftState.b)).toBe(baseState.b)25 })26 })2728 it("should return the original from the proxy", () => {29 produce(baseState, draftState => {30 expect(original(draftState)).toBe(baseState)31 expect(original(draftState.a)).toBe(baseState.a)32 expect(original(draftState.b)).toBe(baseState.b)33 })34 })3536 it("should return undefined for new values on the draft", () => {37 produce(baseState, draftState => {38 draftState.c = {}39 draftState.d = 340 expect(original(draftState.c)).toBeUndefined()41 expect(original(draftState.d)).toBeUndefined()42 })43 })4445 it("should return undefined for an object that is not proxied", () => {46 expect(original({})).toBeUndefined()47 expect(original(3)).toBeUndefined()48 })49})