Skip to content

Commit

Permalink
✅ test: Array functions are inverse transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
joebobmiles committed Jul 9, 2021
1 parent 73c2aa6 commit 5dde179
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/utility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,26 @@ describe("yArrayToArray", () =>
expect(yArrayToArray(yarray)).toEqual(array);
});
});

describe("arrayToYArray and yArrayToArray are inverses", () =>
{
it.each([
[
[]
],
[
[ 1 ]
],
[
[ 1, 2, 3, 4 ]
]
])("Converts arrays back into their original form. (#%#)", (array) =>
{
const ydoc = new Y.Doc();
const ymap = ydoc.getMap("tmp");

ymap.set("array", arrayToYArray(array));

expect(yArrayToArray(ymap.get("array"))).toEqual(array);
});
});

0 comments on commit 5dde179

Please sign in to comment.