Skip to content
Myr

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 file

Take 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 back
1"use strict"

Merge pull request #536 from immerjs/multi-bundleMichel Weststratebefore adoption0d87fc8

lines 2–4why, one step back
2import produce, {original, setUseProxies, enableAllPlugins} from "../src/immer"
34enableAllPlugins()

docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585

line 5why, one step back
5

chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec

lines 6–7why, one step back
6const isProd = process.env.NODE_ENV === "production"
7

docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585

lines 8–39why, one step back
8describe("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 })39

Immer 7Michel Weststratebefore adoption467ea5d

line 40why, one step back
40 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 back
41 produce(baseState, draftState => {
42 draftState.c = {}43 draftState.d = 3

Immer 7Michel Weststratebefore adoption467ea5d

line 44why, one step back
44 expect(() => original(draftState.c)).toThrowErrorMatchingInlineSnapshot(

chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec

lines 45–47why, one step back
45 isProd
46 ? `"[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 back
48 )
49 expect(() => original(draftState.d)).toThrowErrorMatchingInlineSnapshot(

chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec

lines 50–52why, one step back
50 isProd
51 ? `"[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 back
53 )

docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585

lines 54–57why, one step back
54 })
55 })5657 it("should return undefined for an object that is not proxied", () => {

Immer 7Michel Weststratebefore adoption467ea5d

line 58why, one step back
58 expect(() => original({})).toThrowErrorMatchingInlineSnapshot(

chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec

lines 59–61why, one step back
59 isProd
60 ? `"[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 back
62 )
63 expect(() => original(3)).toThrowErrorMatchingInlineSnapshot(

chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec

lines 64–66why, one step back
64 isProd
65 ? `"[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 back
67 )

docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585

lines 68–69why, one step back
68 })
69})