diff --git a/README.md b/README.md index 8d9f08f..f97afdd 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,6 @@ console.log(stats(workout)); - Unsupported params: message duration & y-position - More restricted syntax for text (with quotes) - Support for tags -- Allow skipping power target of any interval, switching it to FreeIntensity. [zwift]: https://zwift.com/ [zwofactory]: https://zwofactory.com/ diff --git a/src/parser/parser.test.ts b/src/parser/parser.test.ts index effe310..2a6426f 100644 --- a/src/parser/parser.test.ts +++ b/src/parser/parser.test.ts @@ -239,15 +239,34 @@ FreeRide: 5:00 `); }); + it("Treats any interval without intensity as a free-ride interval", () => { + expect( + parse(` +Name: My Workout + +Interval: 5:00 +`).intervals, + ).toMatchInlineSnapshot(` + Array [ + Object { + "cadence": undefined, + "comments": Array [], + "duration": Duration { + "seconds": 300, + }, + "intensity": FreeIntensity {}, + "type": "Interval", + }, + ] + `); + }); + const parseInterval = (interval: string) => parse(`Name: My Workout\n${interval}`).intervals[0]; - it("requires duration and power parameters to be specified", () => { + it("requires duration parameter to be specified", () => { expect(() => parseInterval("Interval: 50%")).toThrowErrorMatchingInlineSnapshot( `"Duration not specified at line 2 char 1"`, ); - expect(() => parseInterval("Interval: 30:00")).toThrowErrorMatchingInlineSnapshot( - `"Power not specified at line 2 char 1"`, - ); expect(() => parseInterval("Interval: 10rpm")).toThrowErrorMatchingInlineSnapshot( `"Duration not specified at line 2 char 1"`, ); diff --git a/src/parser/parser.ts b/src/parser/parser.ts index ec7dab2..84b2a69 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -106,11 +106,7 @@ const parseIntervalParams = (type: IntervalType, tokens: Token[], loc: SourceLoc throw new ParseError("Duration not specified", loc); } if (!intensity) { - if (type === "FreeRide") { - intensity = new FreeIntensity(); - } else { - throw new ParseError("Power not specified", loc); - } + intensity = new FreeIntensity(); } const [comments, rest] = parseIntervalComments(tokens);