Skip to content
Myr

original.js

This file

Path

__tests__/original.js

57 lines · 1.7 KiB · JavaScript

Last changed by

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

History of this file

Take it

The walk stopped after 200 commits: lines older than 07f5cc9 point at it.

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

line 1why, one step back
1"use strict"

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 2why, one step back
2import {produce, original} from "../src/immer"

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

lines 3–31why, one step back
3
4const isProd = process.env.NODE_ENV === "production"56describe("original", () => {7 const baseState = {8 a: [],9 b: {}10 }1112 it("should return the original from the draft", () => {13 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 })18 })1920 it("should return the original from the proxy", () => {21 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 throw undefined for new values on the draft", () => {29 produce(baseState, draftState => {30 draftState.c = {}31 draftState.d = 3

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 32why, one step back
32 expect(() => original(draftState.c)).toThrowError(

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

line 33why, one step back
33 isProd

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 34–35why, one step back
34 ? `[Immer] minified error nr: 15. Full error at: https://bit.ly/3cXEKWf`
35 : `[Immer] 'original' expects a draft, got: [object Object]`

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

line 36why, one step back
36 )

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 37why, one step back
37 expect(() => original(draftState.d)).toThrowError(

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

line 38why, one step back
38 isProd

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 39–40why, one step back
39 ? `[Immer] minified error nr: 15. Full error at: https://bit.ly/3cXEKWf`
40 : `[Immer] 'original' expects a draft, got: 3`

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

lines 41–45why, one step back
41 )
42 })43 })4445 it("should return undefined for an object that is not proxied", () => {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 46why, one step back
46 expect(() => original({})).toThrowError(

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

line 47why, one step back
47 isProd

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 48–49why, one step back
48 ? `[Immer] minified error nr: 15. Full error at: https://bit.ly/3cXEKWf`
49 : `[Immer] 'original' expects a draft, got: [object Object]`

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

line 50why, one step back
50 )

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 51why, one step back
51 expect(() => original(3)).toThrowError(

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

line 52why, one step back
52 isProd

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 53–54why, one step back
53 ? `[Immer] minified error nr: 15. Full error at: https://bit.ly/3cXEKWf`
54 : `[Immer] 'original' expects a draft, got: 3`

chore(test): fix production build unit testsMichel Weststratebefore adoption07f5cc9

lines 55–57why, one step back
55 )
56 })57})