Skip to content

Commit

Permalink
feat(curriculum): add test number enumeration (freeCodeCamp#55874)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-wu01 authored Aug 29, 2024
1 parent 786a49d commit 4a29f23
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/src/templates/Challenges/components/test-suite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function TestSuite({ tests }: TestSuiteProps): JSX.Element {
pass && !err ? t('icons.passed') : t('icons.failed');
// Remove opening/closing <p> so screen reader will read both
// status message and test text as one block.
text = text.replace(/^<p>|<\/p>$/g, '');
text = `${index + 1}. ${text.replace(/^<p>|<\/p>$/g, '')}`;
return (
<li
className='test-result'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ function* executeTests(testRunner, tests, testTimeout = 5000) {
newTest.stack = stack;
}

newTest.message = newTest.message.replace(/<p>/, `<p>${i + 1}. `);
yield put(updateConsole(newTest.message));
} finally {
testResults.push(newTest);
Expand Down
2 changes: 1 addition & 1 deletion e2e/output.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const outputTexts = {
> 1 | var
| ^`,
empty: `// running tests
You should declare myName with the var keyword, ending with a semicolon
1. You should declare myName with the var keyword, ending with a semicolon
// tests completed`,
passed: `// running tests
// tests completed`
Expand Down
10 changes: 7 additions & 3 deletions e2e/test-suite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ test.describe('Challenge Test Suite Component Tests', () => {
await expect(page.getByTestId('test-result')).toHaveCount(3);
await expect(page.getByText(translations.icons.initial)).toHaveCount(3);
await expect(
page.getByText('You should not change code above the specified comment.')
page.getByText(
'1. You should not change code above the specified comment.'
)
).toBeVisible();
await expect(page.getByText('b should have a value of 7.')).toBeVisible();
await expect(
page.getByText('a should be assigned to b with =.')
page.getByText('2. b should have a value of 7.')
).toBeVisible();
await expect(
page.getByText('3. a should be assigned to b with =.')
).toBeVisible();
});

Expand Down

0 comments on commit 4a29f23

Please sign in to comment.