test(challenge-parser): improve validate-sections test (#62385)

This commit is contained in:
Huyen Nguyen
2025-09-27 20:22:21 +07:00
committed by GitHub
parent fb3be5c018
commit 95b4056e20
2 changed files with 15 additions and 102 deletions

View File

@@ -124,3 +124,5 @@ function validateSections() {
}
module.exports = validateSections;
module.exports.VALID_MARKERS = VALID_MARKERS;
module.exports.NON_HEADING_MARKERS = NON_HEADING_MARKERS;

View File

@@ -4,7 +4,10 @@ import remark from 'remark-parse';
import frontmatter from 'remark-frontmatter';
import addFrontmatter from './add-frontmatter';
import validateSections from './validate-sections';
import validateSections, {
VALID_MARKERS,
NON_HEADING_MARKERS
} from './validate-sections';
const processor = unified()
.use(remark)
@@ -14,107 +17,15 @@ const processor = unified()
describe('validate-sections plugin', () => {
it('should pass when all section markers are valid', () => {
const file = `---
id: test
title: Test
---
# --after-all--
After all hook.
# --after-each--
After each hook.
# --assignment--
Assignment.
# --before-all--
Before all hook.
# --before-each--
Before each hook.
# --description--
Text content.
# --explanation--
Explanation.
# --fillInTheBlank--
Fill in blank.
# --hints--
Hints.
# --instructions--
More text.
# --notes--
Notes.
# --questions--
Video questions.
# --quizzes--
Quiz section.
# --scene--
Scene content.
# --seed--
Seed section.
# --solutions--
Solutions.
# --transcript--
Transcript.
## --answers--
Answers.
## --blanks--
Blanks.
## --quiz--
Individual quiz.
## --seed-contents--
Contents here.
## --sentence--
Sentence.
## --text--
Question text.
## --video-solution--
Video solution.
## --after-user-code--
After code.
## --before-user-code--
Before code.
### --feedback--
Feedback.
### --question--
Quiz question.
#### --answer--
Correct answer.
#### --distractors--
Distractors.
#### --text--
Question text.
--fcc-editable-region--
Editable region.
`;
const file = [
'---',
'id: test',
'title: Test',
'---',
'',
...VALID_MARKERS.map(marker => `${marker}\nDummy content.`),
...NON_HEADING_MARKERS.map(marker => `${marker}\nDummy content.`)
].join('\n');
expect(() => {
processor.runSync(processor.parse(file));