Skip to content

Commit

Permalink
✅ test: Arrays nested in objects are patched
Browse files Browse the repository at this point in the history
  • Loading branch information
joebobmiles committed Jul 12, 2021
1 parent 307b2b1 commit b1a6048
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/patching.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,30 @@ describe("patchSharedType", () =>
.get(1)
.get(1)).toBe(4);
});

it("Applies additions to arrays nested in objects.", () =>
{
ymap.set("map", objectToYMap({ "foo": [ 1, 2 ], }));
patchSharedType(ymap.get("map"), { "foo": [ 1, 2, 3 ], });

expect(ymap.get("map").get("foo")
.get(2)).toBe(3);
});

it("Applies updates to arrays nested in objects.", () =>
{
ymap.set("map", objectToYMap({ "foo": [ 1, 2, 3 ], }));
patchSharedType(ymap.get("map"), { "foo": [ 1, 4, 3 ], });

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

it("Applies deletions to arrays nested in objects.", () =>
{
ymap.set("map", objectToYMap({ "foo": [ 1, 2, 3 ], }));
patchSharedType(ymap.get("map"), { "foo": [ 1, 2 ], });

expect(ymap.get("map").get("foo")).toHaveLength(2);
});
});

0 comments on commit b1a6048

Please sign in to comment.