fix(curriculum): add .trim() to innerText assertions (#61109)

This commit is contained in:
Alex Goldsmith 2025-06-30 10:45:55 -05:00 committed by GitHub
parent f81857068b
commit 1b4af50a75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 9 additions and 9 deletions

View File

@ -67,7 +67,7 @@ Your `figcaption` element's text should be `Cats love lasagna.` You have either
```js
assert(
document.querySelector('figcaption').innerText.match(/Cats love lasagna.?$/i)
document.querySelector('figcaption').innerText.trim().match(/^Cats love lasagna\.?$/i)
);
```

View File

@ -32,7 +32,7 @@ assert(
document
.querySelectorAll('figcaption')[1]
.querySelector('strong')
.innerText.toLowerCase() === 'hate'
.innerText.trim().toLowerCase() === 'hate'
);
```

View File

@ -47,7 +47,7 @@ On the right side of your new checkbox, there should be `label` element with the
const nextElementSibling = document.querySelectorAll('input[type="checkbox"]')?.[2]?.nextElementSibling;
assert.isOk(
nextElementSibling?.nodeName === 'LABEL' &&
nextElementSibling?.innerText?.replace(/\s+/g, '')?.match(/^Energetic$/i)
nextElementSibling?.innerText?.trim().match(/^Energetic$/i)
);
```

View File

@ -22,7 +22,7 @@ assert.exists(document.querySelector('p')?.querySelector('a'));
The anchor text should be `cute cats`.
```js
assert.strictEqual(document.querySelector('a')?.innerText, "cute cats");
assert.strictEqual(document.querySelector('a')?.innerText.trim(), "cute cats");
```
The `href` attribute of the new anchor element should be `https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg`.
@ -40,7 +40,7 @@ assert.strictEqual(code.indexOf("cute cats"),code.lastIndexOf("cute cats"));
The text of the `p` element should still be `Everyone loves cute cats online!`.
```js
assert.strictEqual(document.querySelector('p')?.innerText, "Everyone loves cute cats online!");
assert.strictEqual(document.querySelector('p')?.innerText.trim(), "Everyone loves cute cats online!");
```
# --seed--

View File

@ -64,7 +64,7 @@ Your `figcaption` element's text should be `Cats love lasagna.` You have either
```js
assert.match(
document.querySelector('figcaption')?.innerText, /Cats love lasagna.?$/i
document.querySelector('figcaption')?.innerText?.trim(), /Cats love lasagna.?$/i
);
```

View File

@ -32,7 +32,7 @@ assert.equal(
document
.querySelectorAll('figcaption')[1]
?.querySelector('strong')
?.innerText.toLowerCase(), 'hate'
?.innerText?.trim().toLowerCase(), 'hate'
);
```

View File

@ -22,7 +22,7 @@ assert.exists(document.querySelector('p')?.querySelector('a'));
The anchor text should be `cute cats`.
```js
assert.strictEqual(document.querySelector('a')?.innerText, "cute cats");
assert.strictEqual(document.querySelector('a')?.innerText?.trim(), "cute cats");
```
The `href` attribute of the new anchor element should be `https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg`.
@ -40,7 +40,7 @@ assert.strictEqual(code.indexOf("cute cats"),code.lastIndexOf("cute cats"));
The text of the `p` element should still be `Everyone loves cute cats online!`.
```js
assert.strictEqual(document.querySelector('p')?.innerText, "Everyone loves cute cats online!");
assert.strictEqual(document.querySelector('p')?.innerText?.trim(), "Everyone loves cute cats online!");
```
# --seed--