Test required interval params

This commit is contained in:
Rene Saarsoo 2020-09-21 17:19:52 +03:00
parent ca451fd2d6
commit 4e860d2f3c
1 changed files with 12 additions and 0 deletions

View File

@ -125,6 +125,18 @@ Cooldown: 5:30 70%..45%
const parseInterval = (interval: string) => const parseInterval = (interval: string) =>
parse(`Name: My Workout\n${interval}`).intervals[0]; parse(`Name: My Workout\n${interval}`).intervals[0];
it("requires duration and power parameters to be specified", () => {
expect(() =>
parseInterval("Interval: 50%")
).toThrowErrorMatchingInlineSnapshot(`"Duration not specified"`);
expect(() =>
parseInterval("Interval: 30:00")
).toThrowErrorMatchingInlineSnapshot(`"Power not specified"`);
expect(() =>
parseInterval("Interval: 10rpm")
).toThrowErrorMatchingInlineSnapshot(`"Duration not specified"`);
});
it("parses correct duration formats", () => { it("parses correct duration formats", () => {
expect(parseInterval("Interval: 0:10 50%").duration).toEqual(10); expect(parseInterval("Interval: 0:10 50%").duration).toEqual(10);
expect(parseInterval("Interval: 00:10 50%").duration).toEqual(10); expect(parseInterval("Interval: 00:10 50%").duration).toEqual(10);