From f20d8a7a702e6d0c67f090fedd27600015408d7f Mon Sep 17 00:00:00 2001 From: "Krzysztof G." <60067306+gikf@users.noreply.github.com> Date: Wed, 26 Nov 2025 16:43:08 +0100 Subject: [PATCH] fix(tools): wrong throw causes test to pass (#64159) Co-authored-by: Oliver Eyton-Williams --- tools/challenge-parser/parser/plugins/add-video-question.js | 2 ++ .../parser/plugins/add-video-question.test.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/challenge-parser/parser/plugins/add-video-question.js b/tools/challenge-parser/parser/plugins/add-video-question.js index 6e7706543be..2c2cb404ac1 100644 --- a/tools/challenge-parser/parser/plugins/add-video-question.js +++ b/tools/challenge-parser/parser/plugins/add-video-question.js @@ -110,6 +110,8 @@ function plugin() { questionNode.children?.[0]?.value === '--text--'; if (isStartOfQuestion) { questionTrees.push([questionNode]); + } else if (questionTrees.length === 0) { + throw Error('question text is missing in questions section'); } else { questionTrees[questionTrees.length - 1].push(questionNode); } diff --git a/tools/challenge-parser/parser/plugins/add-video-question.test.js b/tools/challenge-parser/parser/plugins/add-video-question.test.js index a9d1f5651d7..629e0c1cff8 100644 --- a/tools/challenge-parser/parser/plugins/add-video-question.test.js +++ b/tools/challenge-parser/parser/plugins/add-video-question.test.js @@ -104,7 +104,9 @@ describe('add-video-question plugin', () => { // 'The md is missing "x"', so it's obvious how to fix things. it('should throw if the subheadings are outside the question heading', () => { expect.assertions(1); - expect(() => plugin(videoOutOfOrderAST)).toThrow(); + expect(() => plugin(videoOutOfOrderAST, file)).toThrow( + 'question text is missing in questions section' + ); }); it('should NOT throw if there is no question', () => {