Skip to content
Myr

original.js

This file

Path

__tests__/original.js

49 lines · 1.3 KiB · JavaScript

Last changed by

style: use tabsuse-tabsbefore adoptiona9c0fd0

History of this file

Take it

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

test: tiny improvementaleclarsonbefore adoptionee49da3

lines 1–4why, one step back
1"use strict"
2import produce, {original, setUseProxies} from "../src/index"34describe("original", () => {

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 5–8why, one step back
5 const baseState = {
6 a: [],7 b: {}8 }

test: tiny improvementaleclarsonbefore adoptionee49da3

line 9why, one step back
9

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 10–11why, one step back
10 it("should return the original from the draft", () => {
11 setUseProxies(true)

test: tiny improvementaleclarsonbefore adoptionee49da3

line 12why, one step back
12

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 13–17why, one step back
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 })

test: tiny improvementaleclarsonbefore adoptionee49da3

line 18why, one step back
18

style: use tabsuse-tabsbefore adoptiona9c0fd0

line 19why, one step back
19 setUseProxies(false)

test: tiny improvementaleclarsonbefore adoptionee49da3

line 20why, one step back
20

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 21–26why, one step back
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 })

test: tiny improvementaleclarsonbefore adoptionee49da3

line 27why, one step back
27

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 28–34why, one step back
28 it("should return the original from the proxy", () => {
29 produce(baseState, draftState => {30 expect(original(draftState)).toBe(baseState)31 expect(original(draftState.a)).toBe(baseState.a)32 expect(original(draftState.b)).toBe(baseState.b)33 })34 })

test: tiny improvementaleclarsonbefore adoptionee49da3

line 35why, one step back
35

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 36–43why, one step back
36 it("should return undefined for new values on the draft", () => {
37 produce(baseState, draftState => {38 draftState.c = {}39 draftState.d = 340 expect(original(draftState.c)).toBeUndefined()41 expect(original(draftState.d)).toBeUndefined()42 })43 })

test: tiny improvementaleclarsonbefore adoptionee49da3

line 44why, one step back
44

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 45–48why, one step back
45 it("should return undefined for an object that is not proxied", () => {
46 expect(original({})).toBeUndefined()47 expect(original(3)).toBeUndefined()48 })

test: tiny improvementaleclarsonbefore adoptionee49da3

line 49why, one step back
49})