Add recordOf

This commit is contained in:
Endeavorance 2025-05-22 14:26:11 -04:00
parent fced3e7c65
commit 03b0949d39
3 changed files with 55 additions and 1 deletions

View file

@ -319,3 +319,23 @@ describe(Parse.oneOf, () => {
}
});
});
describe(Parse.recordOf, () => {
test("Parses records of a specific type", () => {
const stringToString = Parse.recordOf(Parse.string, Parse.string);
const rec = {
key: "value",
another: "another",
};
const badRec = {
key: "value",
another: 1,
};
expect(stringToString(rec)).toEqual(rec);
expect(() => stringToString(badRec)).toThrow(ParseError);
});
});