fix(curriculum): fix regex issues and improve trivia-bot test flexibility (#58515)

This commit is contained in:
Eric Do
2025-02-03 13:14:48 -08:00
committed by GitHub
parent d2effdaa41
commit c10a9aa06d
@@ -79,8 +79,8 @@ You should give `codingFact` a value that includes `favoriteLanguage` using con
```js
const codeWithoutComments = __helpers.removeJSComments(code);
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|')?.+?\2?\s*\+\s*favoriteLanguage/g)
assert.match(code, /let\scodingFact\s*=\s*("|')?.+?\1?\s*\+\s*favoriteLanguage/)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*(("|')?.+?\2?\s*\+\s*|favoriteLanguage\s*\+\s*(("|')?.+?\2?))/g);
assert.match(code, /let\scodingFact\s*=\s*(("|')?.+?\1?\s*\+\s*|favoriteLanguage\s*\+\s*(("|')?.+?\3?))/);
assert.include(first, 'let');
assert.exists(first);
assert.isNotEmpty(codingFact);
@@ -100,7 +100,7 @@ You should assign a new value to `codingFact` that also contains `favoriteLangua
```js
const codeWithoutComments = __helpers.removeJSComments(code);
const loggingCodingFacts = codeWithoutComments.match(/console\.log\(\s*codingFact\s*\)/g)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|')?.+?\2?\s*\+\s*favoriteLanguage/g)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*(("|')?.+?\2?\s*\+\s*|favoriteLanguage\s*\+\s*(("|')?.+?\2?))/g);
assert.include(output[4], favoriteLanguage);
assert.notEqual(output[4], output[3]);
assert.isAtLeast(loggingCodingFacts.length, 2);
@@ -113,7 +113,7 @@ You should assign a value to `codingFact` for the third time that also contains
```js
const codeWithoutComments = __helpers.removeJSComments(code);
const loggingCodingFacts = codeWithoutComments.match(/console\.log\(\s*codingFact\s*\)/g)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|')?.+?\2?\s*\+\s*favoriteLanguage/g)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*(("|')?.+?\2?\s*\+\s*|favoriteLanguage\s*\+\s*(("|')?.+?\2?))/g);
assert.include(output[5], favoriteLanguage);
assert.notEqual(output[5], output[4]);
assert.equal(output[5], codingFact);