Skip to content

Commit f20d8a7

Browse files
fix(tools): wrong throw causes test to pass (freeCodeCamp#64159)
Co-authored-by: Oliver Eyton-Williams <[email protected]>
1 parent 9531c9d commit f20d8a7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

tools/challenge-parser/parser/plugins/add-video-question.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ function plugin() {
110110
questionNode.children?.[0]?.value === '--text--';
111111
if (isStartOfQuestion) {
112112
questionTrees.push([questionNode]);
113+
} else if (questionTrees.length === 0) {
114+
throw Error('question text is missing in questions section');
113115
} else {
114116
questionTrees[questionTrees.length - 1].push(questionNode);
115117
}

tools/challenge-parser/parser/plugins/add-video-question.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ describe('add-video-question plugin', () => {
104104
// 'The md is missing "x"', so it's obvious how to fix things.
105105
it('should throw if the subheadings are outside the question heading', () => {
106106
expect.assertions(1);
107-
expect(() => plugin(videoOutOfOrderAST)).toThrow();
107+
expect(() => plugin(videoOutOfOrderAST, file)).toThrow(
108+
'question text is missing in questions section'
109+
);
108110
});
109111

110112
it('should NOT throw if there is no question', () => {

0 commit comments

Comments
 (0)