Workout header parsing tests
This commit is contained in:
parent
8e813276ad
commit
d2d998b160
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue