mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(tools): update error message for hints without tests (#64354)
Co-authored-by: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com> Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,9 @@ function plugin() {
|
|||||||
function transformer(tree, file) {
|
function transformer(tree, file) {
|
||||||
const hintNodes = getSection(tree, '--hints--');
|
const hintNodes = getSection(tree, '--hints--');
|
||||||
if (hintNodes.length % 2 !== 0)
|
if (hintNodes.length % 2 !== 0)
|
||||||
throw Error('Tests must be in (text, ```testString```) order');
|
throw Error(
|
||||||
|
'Hints must be in pairs: each hint text followed by a test code block'
|
||||||
|
);
|
||||||
|
|
||||||
const tests = chunk(hintNodes, 2).map(getTest);
|
const tests = chunk(hintNodes, 2).map(getTest);
|
||||||
file.data.tests = tests;
|
file.data.tests = tests;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ describe('add-tests plugin', () => {
|
|||||||
it('should throw if a test pair is out of order', () => {
|
it('should throw if a test pair is out of order', () => {
|
||||||
// TODO: update the markdown so it makes this error
|
// TODO: update the markdown so it makes this error
|
||||||
expect(() => plugin(brokenHintsAST, file)).toThrow(
|
expect(() => plugin(brokenHintsAST, file)).toThrow(
|
||||||
'Tests must be in (text, ```testString```) order'
|
'Hints must be in pairs: each hint text followed by a test code block'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user