fix(tools): wrong throw causes test to pass (#64159)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Krzysztof G.
2025-11-26 16:43:08 +01:00
committed by GitHub
parent 9531c9d20c
commit f20d8a7a70
2 changed files with 5 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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', () => {