From d2d998b16016f6637a5bc01c726da908eb66086e Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Mon, 21 Sep 2020 16:38:10 +0300 Subject: [PATCH] Workout header parsing tests --- package.json | 1 + src/parser/parser.test.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/package.json b/package.json index cd619c7..5eb6f5f 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "lint:ts": "tsc --noEmit", "lint:js": "eslint src/**/* .eslintrc.js", "test": "jest", + "test:watch": "jest --watch", "test:1": "ts-node src/index.ts examples/threshold-pushing.txt", "test:2": "ts-node src/index.ts examples/darth-vader.txt", "test:stats:1": "ts-node src/index.ts --stats examples/threshold-pushing.txt", diff --git a/src/parser/parser.test.ts b/src/parser/parser.test.ts index 9366816..9478395 100644 --- a/src/parser/parser.test.ts +++ b/src/parser/parser.test.ts @@ -10,4 +10,38 @@ describe("Parser", () => { `"Workout is missing a name. Use \`Name:\` to declare one."` ); }); + + it("parses workout with just Name field", () => { + expect(parse(`Name: My Workout`)).toMatchInlineSnapshot(` + Object { + "author": "", + "description": "", + "intervals": Array [], + "name": "My Workout", + } + `); + }); + + it("parses workout header with all fields", () => { + expect( + parse(`Name: My Workout +Author: John Doe +Description: + It's a great workout. + + Do it when you dare, + it'll cause lots of pain. +`) + ).toMatchInlineSnapshot(` + Object { + "author": "John Doe", + "description": "It's a great workout. + + Do it when you dare, + it'll cause lots of pain.", + "intervals": Array [], + "name": "My Workout", + } + `); + }); });