Skip to content

Commit

Permalink
✅ test: Performs deletes on the sharedType
Browse files Browse the repository at this point in the history
  • Loading branch information
joebobmiles committed Jul 9, 2021
1 parent 82ee5d0 commit 1ad2529
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/patching.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,15 @@ describe("patchSharedType", () =>

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

it("Applies deletes to the given shared type.", () =>
{
const ydoc = new Y.Doc();
const ymap = ydoc.getMap("tmp");

ymap.set("state", objectToYMap({ "foo": 1, }));
patchSharedType({ "foo": 1, }, { }, ymap.get("state"));

expect(Array.from(ymap.get("state").keys())).toEqual([]);
});
});
6 changes: 6 additions & 0 deletions src/patching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ export const patchSharedType = (

break;

case "delete":
if (sharedType instanceof Y.Map)
sharedType.delete(property as string);

break;

default:
break;
}
Expand Down

0 comments on commit 1ad2529

Please sign in to comment.