Skip to content

Commit b29bb09

Browse files
author
Sascha Goldhofer
committed
chore: fix type issue
1 parent 18441eb commit b29bb09

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/getDraftTests.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ function readTestFile(filepath: string): TestCase[] {
2020

2121
function getFilenameAttributes(filename: string) {
2222
let relative = filename.split(/draft[^/]+\//).pop();
23+
if (relative == null) {
24+
throw new Error(`Error in spec generation. Failed parsing filename '${filename}'`)
25+
}
2326
relative = relative.replace(".json", "").replace(/^\//, "");
2427
const attributes = relative.replace(".json", "").split("/");
25-
const optional = attributes[0] === "optional" ? attributes.shift() && true : false;
28+
let optional = false;
29+
if (attributes[0] === "optional") {
30+
attributes.shift();
31+
optional = true;
32+
}
2633
return { optional, name: attributes.join("-") };
2734
}
2835

0 commit comments

Comments
 (0)