mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-19 21:09:51 +08:00
fix(curriculum): add .trim() to innerText assertions (#61109)
This commit is contained in:
parent
f81857068b
commit
1b4af50a75
@ -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)
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ assert(
|
||||
document
|
||||
.querySelectorAll('figcaption')[1]
|
||||
.querySelector('strong')
|
||||
.innerText.toLowerCase() === 'hate'
|
||||
.innerText.trim().toLowerCase() === 'hate'
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@ -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)
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@ -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--
|
||||
|
||||
@ -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
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ assert.equal(
|
||||
document
|
||||
.querySelectorAll('figcaption')[1]
|
||||
?.querySelector('strong')
|
||||
?.innerText.toLowerCase(), 'hate'
|
||||
?.innerText?.trim().toLowerCase(), 'hate'
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@ -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--
|
||||
|
||||
Loading…
Reference in New Issue
Block a user