Add recordOf
This commit is contained in:
parent
fced3e7c65
commit
03b0949d39
3 changed files with 55 additions and 1 deletions
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue