patch.js
This file
Path
__tests__/patch.js
706 lines · 16.7 KiB · JavaScript
Last changed by
feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
History of this fileTake it
The walk stopped after 200 commits: lines older than 53e9ce8 point at it.
perf: proxy assignaleclarsonbefore adoption53e9ce8
line 1why, one step back1"use strict"chore: update import paths in testsaleclarsonbefore adoptioncdc09b1
line 2why, one step back2import produce, {setUseProxies, applyPatches} from "../src/index"perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 3–5why, one step back34jest.setTimeout(1000)5feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 6why, one step back6function runPatchTest(base, producer, patches, inversePathes) {perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 7–9why, one step back7 function runPatchTestHelper() {8 let recordedPatches9 let recordedInversePatchesfeat: `Set` draftsAndrey Goncharovbefore adoption4355b63
line 10why, one step back10perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 11–31why, one step back11 const res = produce(base, producer, (p, i) => {12 recordedPatches = p13 recordedInversePatches = i14 })1516 test("produces the correct patches", () => {17 expect(recordedPatches).toEqual(patches)18 if (inversePathes)19 expect(recordedInversePatches).toEqual(inversePathes)20 })2122 test("patches are replayable", () => {23 expect(applyPatches(base, recordedPatches)).toEqual(res)24 })2526 test("patches can be reversed", () => {27 expect(applyPatches(res, recordedInversePatches)).toEqual(base)28 })29 }3031 describe(`proxy`, () => {feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
line 32why, one step back32 beforeAll(() => setUseProxies(true))perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 33–36why, one step back33 runPatchTestHelper()34 })3536 describe(`es5`, () => {feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
lines 37–38why, one step back37 beforeAll(() => setUseProxies(false))38 runPatchTestHelper()perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 39–42why, one step back39 })40}4142describe("applyPatches", () => {fix: applyPatches should mutate draftsaleclarsonbefore adoptiond41be77
lines 43–60why, one step back43 it("mutates the base state when it is a draft", () => {44 produce({a: 1}, draft => {45 const result = applyPatches(draft, [46 {op: "replace", path: ["a"], value: 2}47 ])48 expect(result).toBe(draft)49 expect(draft.a).toBe(2)50 })51 })52 it("produces a copy of the base state when not a draft", () => {53 const base = {a: 1}54 const result = applyPatches(base, [55 {op: "replace", path: ["a"], value: 2}56 ])57 expect(result).not.toBe(base)58 expect(result.a).toBe(2)59 expect(base.a).toBe(1)60 })perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 61–64why, one step back61 it('throws when `op` is not "add", "replace", nor "remove"', () => {62 expect(() => {63 const patch = {op: "copy", from: [0], path: [1]}64 applyPatches([2], [patch])test: use Jest snapshots for expected errorsAlec Larsonbefore adoption0ad9a91
line 65why, one step back65 }).toThrowErrorMatchingSnapshot()perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 66–71why, one step back66 })67 it("throws when `path` cannot be resolved", () => {68 // missing parent69 expect(() => {70 const patch = {op: "add", path: ["a", "b"], value: 1}71 applyPatches({}, [patch])test: use Jest snapshots for expected errorsAlec Larsonbefore adoption0ad9a91
line 72why, one step back72 }).toThrowErrorMatchingSnapshot()perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 73–77why, one step back7374 // missing grand-parent75 expect(() => {76 const patch = {op: "add", path: ["a", "b", "c"], value: 1}77 applyPatches({}, [patch])test: use Jest snapshots for expected errorsAlec Larsonbefore adoption0ad9a91
line 78why, one step back78 }).toThrowErrorMatchingSnapshot()perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 79–101why, one step back79 })80})8182describe("simple assignment - 1", () => {83 runPatchTest(84 {x: 3},85 d => {86 d.x++87 },88 [{op: "replace", path: ["x"], value: 4}]89 )90})9192describe("simple assignment - 2", () => {93 runPatchTest(94 {x: {y: 4}},95 d => {96 d.x.y++97 },98 [{op: "replace", path: ["x", "y"], value: 5}]99 )100})101feat: improved array patchesIlyas Kabirovbefore adoptioncb5707f
lines 102–111why, one step back102describe("simple assignment - 3", () => {103 runPatchTest(104 {x: [{y: 4}]},105 d => {106 d.x[0].y++107 },108 [{op: "replace", path: ["x", 0, "y"], value: 5}]109 )110})111feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 112–118why, one step back112describe("simple assignment - 4", () => {113 runPatchTest(114 new Map([["x", {y: 4}]]),115 d => {116 d.get("x").y++117 },118 [{op: "replace", path: ["x", "y"], value: 5}],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 119why, one step back119 [{op: "replace", path: ["x", "y"], value: 4}]feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 120–129why, one step back120 )121})122123describe("simple assignment - 5", () => {124 runPatchTest(125 {x: new Map([["y", 4]])},126 d => {127 d.x.set("y", 5)128 },129 [{op: "replace", path: ["x", "y"], value: 5}],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 130why, one step back130 [{op: "replace", path: ["x", "y"], value: 4}]feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 131–133why, one step back131 )132})133fix: Map.prototype.set should return a draftAndrey Goncharovbefore adoption7001201
lines 134–145why, one step back134describe("simple assignment - 6", () => {135 runPatchTest(136 new Map([["x", 1]]),137 d => {138 // Map.prototype.set should return the Map itself139 const res = d.set("x", 2)140 res.set("y", 3)141 },142 [143 {op: "replace", path: ["x"], value: 2},144 {op: "add", path: ["y"], value: 3}145 ],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 146why, one step back146 [{op: "replace", path: ["x"], value: 1}, {op: "remove", path: ["y"]}]fix: Map.prototype.set should return a draftAndrey Goncharovbefore adoption7001201
lines 147–149why, one step back147 )148})149feat: add support of non-primitive keys for `Maps`keenondrumsbefore adoption6501ec5
lines 150–165why, one step back150describe("simple assignment - 7", () => {151 const key1 = {prop: "val1"}152 const key2 = {prop: "val2"}153 runPatchTest(154 {x: new Map([[key1, 4]])},155 d => {156 d.x.set(key1, 5)157 d.x.set(key2, 6)158 },159 [160 {op: "replace", path: ["x", key1], value: 5},161 {op: "add", path: ["x", key2], value: 6}162 ],163 [164 {op: "replace", path: ["x", key1], value: 4},165 {op: "remove", path: ["x", key2]}feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 166why, one step back166 ]feat: add support of non-primitive keys for `Maps`keenondrumsbefore adoption6501ec5
lines 167–169why, one step back167 )168})169perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 170–179why, one step back170describe("delete 1", () => {171 runPatchTest(172 {x: {y: 4}},173 d => {174 delete d.x175 },176 [{op: "remove", path: ["x"]}]177 )178})179feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 180–186why, one step back180describe("delete 2", () => {181 runPatchTest(182 new Map([["x", 1]]),183 d => {184 d.delete("x")185 },186 [{op: "remove", path: ["x"]}],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 187why, one step back187 [{op: "add", path: ["x"], value: 1}]feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 188–197why, one step back188 )189})190191describe("delete 3", () => {192 runPatchTest(193 {x: new Map([["y", 1]])},194 d => {195 d.x.delete("y")196 },197 [{op: "remove", path: ["x", "y"]}],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 198why, one step back198 [{op: "add", path: ["x", "y"], value: 1}]feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 199–201why, one step back199 )200})201feat: add support of non-primitive keys for `Maps`keenondrumsbefore adoption6501ec5
lines 202–204why, one step back202describe("delete 5", () => {203 const key1 = {prop: "val1"}204 const key2 = {prop: "val2"}feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
line 205why, one step back205 runPatchTest(feat: add support of non-primitive keys for `Maps`keenondrumsbefore adoption6501ec5
lines 206–214why, one step back206 {x: new Map([[key1, 1], [key2, 2]])},207 d => {208 d.x.delete(key1)209 d.x.delete(key2)210 },211 [{op: "remove", path: ["x", key1]}, {op: "remove", path: ["x", key2]}],212 [213 {op: "add", path: ["x", key1], value: 1},214 {op: "add", path: ["x", key2], value: 2}feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 215why, one step back215 ]feat: add support of non-primitive keys for `Maps`keenondrumsbefore adoption6501ec5
lines 216–220why, one step back216 )217})218219describe("delete 6", () => {220 runPatchTest(feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 221–225why, one step back221 new Set(["x", 1]),222 d => {223 d.delete("x")224 },225 [{op: "remove", path: [0], value: "x"}],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 226why, one step back226 [{op: "add", path: [0], value: "x"}]feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 227–229why, one step back227 )228})229feat: add support of non-primitive keys for `Maps`keenondrumsbefore adoption6501ec5
line 230why, one step back230describe("delete 7", () => {feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 231–236why, one step back231 runPatchTest(232 {x: new Set(["y", 1])},233 d => {234 d.x.delete("y")235 },236 [{op: "remove", path: ["x", 0], value: "y"}],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 237why, one step back237 [{op: "add", path: ["x", 0], value: "y"}]feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 238–240why, one step back238 )239})240perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 241–255why, one step back241describe("renaming properties", () => {242 describe("nested object (no changes)", () => {243 runPatchTest(244 {a: {b: 1}},245 d => {246 d.x = d.a247 delete d.a248 },249 [250 {op: "add", path: ["x"], value: {b: 1}},251 {op: "remove", path: ["a"]}252 ]253 )254 })255feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 256–269why, one step back256 describe("nested map (no changes)", () => {257 runPatchTest(258 new Map([["a", new Map([["b", 1]])]]),259 d => {260 d.set("x", d.get("a"))261 d.delete("a")262 },263 [264 {op: "add", path: ["x"], value: new Map([["b", 1]])},265 {op: "remove", path: ["a"]}266 ],267 [268 {op: "remove", path: ["x"]},269 {op: "add", path: ["a"], value: new Map([["b", 1]])}feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 270why, one step back270 ]feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 271–273why, one step back271 )272 })273perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 274–293why, one step back274 describe("nested object (with changes)", () => {275 runPatchTest(276 {a: {b: 1, c: 1}},277 d => {278 let a = d.a279 a.b = 2 // change280 delete a.c // delete281 a.y = 2 // add282283 // rename284 d.x = a285 delete d.a286 },287 [288 {op: "add", path: ["x"], value: {b: 2, y: 2}},289 {op: "remove", path: ["a"]}290 ]291 )292 })293feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 294–313why, one step back294 describe("nested map (with changes)", () => {295 runPatchTest(296 new Map([["a", new Map([["b", 1], ["c", 1]])]]),297 d => {298 let a = d.get("a")299 a.set("b", 2) // change300 a.delete("c") // delete301 a.set("y", 2) // add302303 // rename304 d.set("x", a)305 d.delete("a")306 },307 [308 {op: "add", path: ["x"], value: new Map([["b", 2], ["y", 2]])},309 {op: "remove", path: ["a"]}310 ],311 [312 {op: "remove", path: ["x"]},313 {op: "add", path: ["a"], value: new Map([["b", 1], ["c", 1]])}feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 314why, one step back314 ]feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 315–317why, one step back315 )316 })317perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 318–336why, one step back318 describe("deeply nested object (with changes)", () => {319 runPatchTest(320 {a: {b: {c: 1, d: 1}}},321 d => {322 let b = d.a.b323 b.c = 2 // change324 delete b.d // delete325 b.y = 2 // add326327 // rename328 d.a.x = b329 delete d.a.b330 },331 [332 {op: "add", path: ["a", "x"], value: {c: 2, y: 2}},333 {op: "remove", path: ["a", "b"]}334 ]335 )336 })feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 337–365why, one step back337338 describe("deeply nested map (with changes)", () => {339 runPatchTest(340 new Map([["a", new Map([["b", new Map([["c", 1], ["d", 1]])]])]]),341 d => {342 let b = d.get("a").get("b")343 b.set("c", 2) // change344 b.delete("d") // delete345 b.set("y", 2) // add346347 // rename348 d.get("a").set("x", b)349 d.get("a").delete("b")350 },351 [352 {353 op: "add",354 path: ["a", "x"],355 value: new Map([["c", 2], ["y", 2]])356 },357 {op: "remove", path: ["a", "b"]}358 ],359 [360 {op: "remove", path: ["a", "x"]},361 {362 op: "add",363 path: ["a", "b"],364 value: new Map([["c", 1], ["d", 1]])365 }feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 366why, one step back366 ]feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 367–368why, one step back367 )368 })perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 369–391why, one step back369})370371describe("minimum amount of changes", () => {372 runPatchTest(373 {x: 3, y: {a: 4}, z: 3},374 d => {375 d.y.a = 4376 d.y.b = 5377 Object.assign(d, {x: 4, y: {a: 2}})378 },379 [380 {op: "replace", path: ["x"], value: 4},381 {op: "replace", path: ["y"], value: {a: 2}}382 ]383 )384})385386describe("arrays - prepend", () => {387 runPatchTest(388 {x: [1, 2, 3]},389 d => {390 d.x.unshift(4)391 },feat: improved array patchesIlyas Kabirovbefore adoptioncb5707f
lines 392–402why, one step back392 [{op: "add", path: ["x", 0], value: 4}]393 )394})395396describe("arrays - multiple prepend", () => {397 runPatchTest(398 {x: [1, 2, 3]},399 d => {400 d.x.unshift(4)401 d.x.unshift(5)402 },perf: proxy assignaleclarsonbefore adoption53e9ce8
line 403why, one step back403 [feat: improved array patchesIlyas Kabirovbefore adoptioncb5707f
lines 404–405why, one step back404 {op: "add", path: ["x", 0], value: 5},405 {op: "add", path: ["x", 1], value: 4}perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 406–415why, one step back406 ]407 )408})409410describe("arrays - splice middle", () => {411 runPatchTest(412 {x: [1, 2, 3]},413 d => {414 d.x.splice(1, 1)415 },feat: improved array patchesIlyas Kabirovbefore adoptioncb5707f
lines 416–426why, one step back416 [{op: "remove", path: ["x", 1]}]417 )418})419420describe("arrays - multiple splice", () => {421 runPatchTest(422 [0, 1, 2, 3, 4, 5, 0],423 d => {424 d.splice(4, 2, 3)425 d.splice(1, 2, 3)426 },perf: proxy assignaleclarsonbefore adoption53e9ce8
line 427why, one step back427 [feat: improved array patchesIlyas Kabirovbefore adoptioncb5707f
lines 428–444why, one step back428 {op: "replace", path: [1], value: 3},429 {op: "replace", path: [2], value: 3},430 {op: "remove", path: [5]},431 {op: "remove", path: [4]}432 ]433 )434})435436describe("arrays - modify and shrink", () => {437 runPatchTest(438 {x: [1, 2, 3]},439 d => {440 d.x[0] = 4441 d.x.length = 2442 },443 [444 {op: "replace", path: ["x", 0], value: 4},perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 445–513why, one step back445 {op: "replace", path: ["x", "length"], value: 2}446 ]447 )448})449450describe("arrays - prepend then splice middle", () => {451 runPatchTest(452 {x: [1, 2, 3]},453 d => {454 d.x.unshift(4)455 d.x.splice(2, 1)456 },457 [458 {op: "replace", path: ["x", 0], value: 4},459 {op: "replace", path: ["x", 1], value: 1}460 ]461 )462})463464describe("arrays - splice middle then prepend", () => {465 runPatchTest(466 {x: [1, 2, 3]},467 d => {468 d.x.splice(1, 1)469 d.x.unshift(4)470 },471 [472 {op: "replace", path: ["x", 0], value: 4},473 {op: "replace", path: ["x", 1], value: 1}474 ]475 )476})477478describe("arrays - truncate", () => {479 runPatchTest(480 {x: [1, 2, 3]},481 d => {482 d.x.length -= 2483 },484 [{op: "replace", path: ["x", "length"], value: 1}],485 [486 {op: "add", path: ["x", 1], value: 2},487 {op: "add", path: ["x", 2], value: 3}488 ]489 )490})491492describe("arrays - pop twice", () => {493 runPatchTest(494 {x: [1, 2, 3]},495 d => {496 d.x.pop()497 d.x.pop()498 },499 [{op: "replace", path: ["x", "length"], value: 1}]500 )501})502503describe("arrays - push multiple", () => {504 runPatchTest(505 {x: [1, 2, 3]},506 d => {507 d.x.push(4, 5)508 },509 [510 {op: "add", path: ["x", 3], value: 4},511 {op: "add", path: ["x", 4], value: 5}512 ],513 [{op: "replace", path: ["x", "length"], value: 3}]feat: improved array patchesIlyas Kabirovbefore adoptioncb5707f
lines 514–551why, one step back514 )515})516517describe("arrays - splice (expand)", () => {518 runPatchTest(519 {x: [1, 2, 3]},520 d => {521 d.x.splice(1, 1, 4, 5, 6)522 },523 [524 {op: "replace", path: ["x", 1], value: 4},525 {op: "add", path: ["x", 2], value: 5},526 {op: "add", path: ["x", 3], value: 6}527 ],528 [529 {op: "replace", path: ["x", 1], value: 2},530 {op: "remove", path: ["x", 3]},531 {op: "remove", path: ["x", 2]}532 ]533 )534})535536describe("arrays - splice (shrink)", () => {537 runPatchTest(538 {x: [1, 2, 3, 4, 5]},539 d => {540 d.x.splice(1, 3, 6)541 },542 [543 {op: "replace", path: ["x", 1], value: 6},544 {op: "remove", path: ["x", 3]},545 {op: "remove", path: ["x", 2]}546 ],547 [548 {op: "replace", path: ["x", 1], value: 2},549 {op: "add", path: ["x", 2], value: 3},550 {op: "add", path: ["x", 3], value: 4}551 ]perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 552–554why, one step back552 )553})554feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 555–561why, one step back555describe("sets - add - 1", () => {556 runPatchTest(557 new Set([1]),558 d => {559 d.add(2)560 },561 [{op: "add", path: [1], value: 2}],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 562why, one step back562 [{op: "remove", path: [1], value: 2}]feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 563–574why, one step back563 )564})565566describe("sets - add, delete, add - 1", () => {567 runPatchTest(568 new Set([1]),569 d => {570 d.add(2)571 d.delete(2)572 d.add(2)573 },574 [{op: "add", path: [1], value: 2}],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 575why, one step back575 [{op: "remove", path: [1], value: 2}]feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 576–587why, one step back576 )577})578579describe("sets - add, delete, add - 2", () => {580 runPatchTest(581 new Set([2, 1]),582 d => {583 d.add(2)584 d.delete(2)585 d.add(2)586 },587 [],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 588why, one step back588 []feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 589–616why, one step back589 )590})591592describe("sets - mutate - 1", () => {593 const findById = (set, id) => {594 for (const item of set) {595 if (item.id === id) return item596 }597 }598 runPatchTest(599 new Set([{id: 1, val: "We"}, {id: 2, val: "will"}]),600 d => {601 const obj1 = findById(d, 1)602 const obj2 = findById(d, 2)603 obj1.val = "rock"604 obj2.val = "you"605 },606 [607 {op: "remove", path: [0], value: {id: 1, val: "We"}},608 {op: "remove", path: [1], value: {id: 2, val: "will"}},609 {op: "add", path: [0], value: {id: 1, val: "rock"}},610 {op: "add", path: [1], value: {id: 2, val: "you"}}611 ],612 [613 {op: "remove", path: [1], value: {id: 2, val: "you"}},614 {op: "remove", path: [0], value: {id: 1, val: "rock"}},615 {op: "add", path: [1], value: {id: 2, val: "will"}},616 {op: "add", path: [0], value: {id: 1, val: "We"}}feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 617why, one step back617 ]feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 618–620why, one step back618 )619})620perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 621–643why, one step back621describe("simple replacement", () => {622 runPatchTest({x: 3}, _d => 4, [{op: "replace", path: [], value: 4}])623})624625describe("same value replacement - 1", () => {626 runPatchTest(627 {x: {y: 3}},628 d => {629 const a = d.x630 d.x = a631 },632 []633 )634})635636describe("same value replacement - 2", () => {637 runPatchTest(638 {x: {y: 3}},639 d => {640 const a = d.x641 d.x = 4642 d.x = a643 },fix: comparison typoaleclarsonbefore adoption48b371c
line 644why, one step back644 []perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 645–664why, one step back645 )646})647648describe("same value replacement - 3", () => {649 runPatchTest(650 {x: 3},651 d => {652 d.x = 3653 },654 []655 )656})657658describe("same value replacement - 4", () => {659 runPatchTest(660 {x: 3},661 d => {662 d.x = 4663 d.x = 3664 },fix: comparison typoaleclarsonbefore adoption48b371c
line 665why, one step back665 []feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 666–674why, one step back666 )667})668669describe("same value replacement - 5", () => {670 runPatchTest(671 new Map([["x", 3]]),672 d => {673 d.set("x", 4)674 d.set("x", 3)feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 675–676why, one step back675 },676 [],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 677why, one step back677 []feat: `Set` draftsAndrey Goncharovbefore adoption4355b63
lines 678–686why, one step back678 )679})680681describe("same value replacement - 6", () => {682 runPatchTest(683 new Set(["x", 3]),684 d => {685 d.delete("x")686 d.add("x")feat: `Map` drafts and patcheskeenondrumsbefore adoption30db0f3
lines 687–688why, one step back687 },688 [],feat: add es5 support for Map/SetAndrey Boldyrevbefore adoptionea9ba04
line 689why, one step back689 []perf: proxy assignaleclarsonbefore adoption53e9ce8
lines 690–706why, one step back690 )691})692693describe("simple delete", () => {694 runPatchTest(695 {x: 2},696 d => {697 delete d.x698 },699 [700 {701 op: "remove",702 path: ["x"]703 }704 ]705 )706})