Skip to content

Commit

Permalink
✅ test: Confirmed patches work for nested arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
joebobmiles committed Jul 12, 2021
1 parent dd341b1 commit 307b2b1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/patching.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,22 @@ describe("patchSharedType", () =>
.get(1)
.get(0)).toBe(2);
});

it("Applies deletions to arrays nested in arrays.", () =>
{
ymap.set("array", arrayToYArray([ 1, [ 2, 3 ] ]));
patchSharedType(ymap.get("array"), [ 1, [ 2 ] ]);

expect(ymap.get("array").get(1)).toHaveLength(1);
});

it("Applies additions and deletions into updates for nested arrays.", () =>
{
ymap.set("array", arrayToYArray([ 1, [ 2, 3 ] ]));
patchSharedType(ymap.get("array"), [ 1, [ 2, 4 ] ]);

expect(ymap.get("array")
.get(1)
.get(1)).toBe(4);
});
});

0 comments on commit 307b2b1

Please sign in to comment.