Workout header parsing tests

This commit is contained in:
Rene Saarsoo 2020-09-21 16:38:10 +03:00
parent 8e813276ad
commit d2d998b160
2 changed files with 35 additions and 0 deletions

View File

@ -6,6 +6,7 @@
"lint:ts": "tsc --noEmit", "lint:ts": "tsc --noEmit",
"lint:js": "eslint src/**/* .eslintrc.js", "lint:js": "eslint src/**/* .eslintrc.js",
"test": "jest", "test": "jest",
"test:watch": "jest --watch",
"test:1": "ts-node src/index.ts examples/threshold-pushing.txt", "test:1": "ts-node src/index.ts examples/threshold-pushing.txt",
"test:2": "ts-node src/index.ts examples/darth-vader.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", "test:stats:1": "ts-node src/index.ts --stats examples/threshold-pushing.txt",

View File

@ -10,4 +10,38 @@ describe("Parser", () => {
`"Workout is missing a name. Use \`Name:\` to declare one."` `"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",
}
`);
});
}); });