Skip to content
Myr

test: applyPatches coverage

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by aleclarson · committed by aleclarson · parent d671c22 · Browse files · 1 file+26 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+26 added−0 removed

  • tests:+26 added−0 removed

1 file+26 added−0 removed

modified:__tests__/patch.js+26 added
43 unmodified lines
44 const patch = {op: "copy", from: [0], path: [1]}45 applyPatches([2], [patch])46 }).toThrowError(/^Unsupported patch operation:/)47 })48 it("throws when `path` cannot be resolved", () => {49 // missing parent50 expect(() => {51 const patch = {op: "add", path: ["a", "b"], value: 1}52 applyPatches({}, [patch])53 }).toThrowError(/^Cannot apply patch, path doesn't resolve:/)5455 // missing grand-parent56 expect(() => {57 const patch = {op: "add", path: ["a", "b", "c"], value: 1}58 applyPatches({}, [patch])59 }).toThrowError(/^Cannot apply patch, path doesn't resolve:/)60 })61 it("throws when a patch tries to splice an array", () => {62 // Pop is ok63 expect(() => {64 const patch = {op: "remove", path: [0]}65 applyPatches([1], [patch])66 }).not.toThrowError()6768 // Splice is unsupported69 expect(() => {70 const patch = {op: "remove", path: [0]}71 applyPatches([1, 2], [patch])72 }).toThrowError(/^Remove can only remove the last key of an array/)73 })74})7576describe("simple assignment", () => {77 runPatchTest(
223 unmodified lines