original.js
This file
Path
__tests__/original.js
69 lines · 2.2 KiB · JavaScript
Last changed by
chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec
History of this fileTake it
The walk stopped after 200 commits: lines older than fbae585 point at it.
docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585
line 1why, one step back1"use strict"Merge pull request #536 from immerjs/multi-bundleMichel Weststratebefore adoption0d87fc8
lines 2–4why, one step back2import produce, {original, setUseProxies, enableAllPlugins} from "../src/immer"34enableAllPlugins()docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585
line 5why, one step back5chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec
lines 6–7why, one step back6const isProd = process.env.NODE_ENV === "production"7docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585
lines 8–39why, one step back8describe("original", () => {9 const baseState = {10 a: [],11 b: {}12 }1314 it("should return the original from the draft", () => {15 setUseProxies(true)1617 produce(baseState, draftState => {18 expect(original(draftState)).toBe(baseState)19 expect(original(draftState.a)).toBe(baseState.a)20 expect(original(draftState.b)).toBe(baseState.b)21 })2223 setUseProxies(false)2425 produce(baseState, draftState => {26 expect(original(draftState)).toBe(baseState)27 expect(original(draftState.a)).toBe(baseState.a)28 expect(original(draftState.b)).toBe(baseState.b)29 })30 })3132 it("should return the original from the proxy", () => {33 produce(baseState, draftState => {34 expect(original(draftState)).toBe(baseState)35 expect(original(draftState.a)).toBe(baseState.a)36 expect(original(draftState.b)).toBe(baseState.b)37 })38 })39Immer 7Michel Weststratebefore adoption467ea5d
line 40why, one step back40 it("should throw undefined for new values on the draft", () => {docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585
lines 41–43why, one step back41 produce(baseState, draftState => {42 draftState.c = {}43 draftState.d = 3Immer 7Michel Weststratebefore adoption467ea5d
line 44why, one step back44 expect(() => original(draftState.c)).toThrowErrorMatchingInlineSnapshot(chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec
lines 45–47why, one step back45 isProd46 ? `"[Immer] minified error nr: 23 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"`47 : `"[Immer] 'original' expects a draft, got: [object Object]"`Immer 7Michel Weststratebefore adoption467ea5d
lines 48–49why, one step back48 )49 expect(() => original(draftState.d)).toThrowErrorMatchingInlineSnapshot(chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec
lines 50–52why, one step back50 isProd51 ? `"[Immer] minified error nr: 23 '3'. Find the full error at: https://bit.ly/3cXEKWf"`52 : `"[Immer] 'original' expects a draft, got: 3"`Immer 7Michel Weststratebefore adoption467ea5d
line 53why, one step back53 )docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585
lines 54–57why, one step back54 })55 })5657 it("should return undefined for an object that is not proxied", () => {Immer 7Michel Weststratebefore adoption467ea5d
line 58why, one step back58 expect(() => original({})).toThrowErrorMatchingInlineSnapshot(chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec
lines 59–61why, one step back59 isProd60 ? `"[Immer] minified error nr: 23 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"`61 : `"[Immer] 'original' expects a draft, got: [object Object]"`Immer 7Michel Weststratebefore adoption467ea5d
lines 62–63why, one step back62 )63 expect(() => original(3)).toThrowErrorMatchingInlineSnapshot(chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec
lines 64–66why, one step back64 isProd65 ? `"[Immer] minified error nr: 23 '3'. Find the full error at: https://bit.ly/3cXEKWf"`66 : `"[Immer] 'original' expects a draft, got: 3"`Immer 7Michel Weststratebefore adoption467ea5d
line 67why, one step back67 )docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585
lines 68–69why, one step back68 })69})