original.js
This file
Path
__tests__/original.js
59 lines · 1.7 KiB · JavaScript
Last changed by
Immer 7Michel Weststratebefore adoption467ea5d
History of this fileTake it
The walk stopped after 200 commits: lines older than efd47f6 point at it.
chore: improve some testsaleclarsonbefore adoptionefd47f6
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()chore: improve some testsaleclarsonbefore adoptionefd47f6
lines 5–6why, one step back56describe("original", () => {style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 7–10why, one step back7 const baseState = {8 a: [],9 b: {}10 }chore: improve some testsaleclarsonbefore adoptionefd47f6
line 11why, one step back11style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 12–13why, one step back12 it("should return the original from the draft", () => {13 setUseProxies(true)chore: improve some testsaleclarsonbefore adoptionefd47f6
line 14why, one step back14style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 15–19why, one step back15 produce(baseState, draftState => {16 expect(original(draftState)).toBe(baseState)17 expect(original(draftState.a)).toBe(baseState.a)18 expect(original(draftState.b)).toBe(baseState.b)19 })chore: improve some testsaleclarsonbefore adoptionefd47f6
line 20why, one step back20style: use tabsuse-tabsbefore adoptiona9c0fd0
line 21why, one step back21 setUseProxies(false)chore: improve some testsaleclarsonbefore adoptionefd47f6
line 22why, one step back22style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 23–28why, one step back23 produce(baseState, draftState => {24 expect(original(draftState)).toBe(baseState)25 expect(original(draftState.a)).toBe(baseState.a)26 expect(original(draftState.b)).toBe(baseState.b)27 })28 })chore: improve some testsaleclarsonbefore adoptionefd47f6
line 29why, one step back29style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 30–36why, one step back30 it("should return the original from the proxy", () => {31 produce(baseState, draftState => {32 expect(original(draftState)).toBe(baseState)33 expect(original(draftState.a)).toBe(baseState.a)34 expect(original(draftState.b)).toBe(baseState.b)35 })36 })chore: improve some testsaleclarsonbefore adoptionefd47f6
line 37why, one step back37Immer 7Michel Weststratebefore adoption467ea5d
line 38why, one step back38 it("should throw undefined for new values on the draft", () => {style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 39–41why, one step back39 produce(baseState, draftState => {40 draftState.c = {}41 draftState.d = 3Immer 7Michel Weststratebefore adoption467ea5d
lines 42–47why, one step back42 expect(() => original(draftState.c)).toThrowErrorMatchingInlineSnapshot(43 `"[Immer] 'original' expects a draft, got: [object Object]"`44 )45 expect(() => original(draftState.d)).toThrowErrorMatchingInlineSnapshot(46 `"[Immer] 'original' expects a draft, got: 3"`47 )style: use tabsuse-tabsbefore adoptiona9c0fd0
lines 48–49why, one step back48 })49 })chore: improve some testsaleclarsonbefore adoptionefd47f6
line 50why, one step back50style: use tabsuse-tabsbefore adoptiona9c0fd0
line 51why, one step back51 it("should return undefined for an object that is not proxied", () => {Immer 7Michel Weststratebefore adoption467ea5d
lines 52–57why, one step back52 expect(() => original({})).toThrowErrorMatchingInlineSnapshot(53 `"[Immer] 'original' expects a draft, got: [object Object]"`54 )55 expect(() => original(3)).toThrowErrorMatchingInlineSnapshot(56 `"[Immer] 'original' expects a draft, got: 3"`57 )style: use tabsuse-tabsbefore adoptiona9c0fd0
line 58why, one step back58 })chore: improve some testsaleclarsonbefore adoptionefd47f6
line 59why, one step back59})