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 9e12f56 point at it.
docs: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
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: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
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: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
line 8why, one step back8describe("original", () => {style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 9–12why, one step back9 const baseState = {10 a: [],11 b: {}12 }docs: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
line 13why, one step back13style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 14–15why, one step back14 it("should return the original from the draft", () => {15 setUseProxies(true)docs: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
line 16why, one step back16style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 17–21why, one step back17 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 })docs: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
line 22why, one step back22style: use tabsuse-tabsbefore adoptiona9c0fd0
line 23why, one step back23 setUseProxies(false)docs: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
line 24why, one step back24style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 25–30why, one step back25 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 })docs: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
line 31why, one step back31style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 32–38why, one step back32 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 })docs: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
line 39why, one step back39Immer 7Michel Weststratebefore adoption467ea5d
line 40why, one step back40 it("should throw undefined for new values on the draft", () => {style: use tabsuse-tabsbefore adoptiona9c0fd0
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 )style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 54–55why, one step back54 })55 })docs: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
line 56why, one step back56style: use tabsuse-tabsbefore adoptiona9c0fd0
line 57why, one step back57 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 )style: use tabsuse-tabsbefore adoptiona9c0fd0
line 68why, one step back68 })docs: elaborate on immerable symbolAlec Larsonbefore adoption9e12f56
line 69why, one step back69})