From 4e860d2f3c4420582766916d2f12125a648e224d Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Mon, 21 Sep 2020 17:19:52 +0300 Subject: [PATCH] Test required interval params --- src/parser/parser.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/parser/parser.test.ts b/src/parser/parser.test.ts index 93e70c9..2de87db 100644 --- a/src/parser/parser.test.ts +++ b/src/parser/parser.test.ts @@ -125,6 +125,18 @@ Cooldown: 5:30 70%..45% const parseInterval = (interval: string) => 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", () => { expect(parseInterval("Interval: 0:10 50%").duration).toEqual(10); expect(parseInterval("Interval: 00:10 50%").duration).toEqual(10);