Skip to content

Commit

Permalink
fix(curriculum): update test case in cat photo app (freeCodeCamp#58401)
Browse files Browse the repository at this point in the history
Co-authored-by: Ilenia <[email protected]>
  • Loading branch information
timmy471 and ilenia-magoni authored Jan 30, 2025
1 parent 266899a commit 59027fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,34 @@ And its `alt` attribute value to:
There should be an `img` element right after the closing `</ul>` tag.

```js
assert.equal(document.querySelectorAll('section')?.[1]?.lastElementChild?.nodeName, 'IMG');
assert.equal(document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling?.nodeName, 'IMG');
```
The new image does not have an `alt` attribute. Check that there is a space after the opening tag's name and/or there are spaces before all attribute names.
```js
assert.isTrue(document.querySelectorAll('section')?.[1]?.lastElementChild?.hasAttribute('alt'));
assert.isTrue(document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling?.hasAttribute('alt'));
```
The new image should have an `alt` value of `A slice of lasagna on a plate.` Make sure the `alt` attribute's value is surrounded with quotation marks.
```js
assert(
document.querySelectorAll('section')?.[1]
?.lastElementChild?.getAttribute('alt')
.replace(/\s+/g, ' ')
.match(/^A slice of lasagna on a plate\.?$/i)
assert.match(
document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling?.getAttribute('alt')?.replace(/\s+/g, ' '), /^A slice of lasagna on a plate\.?$/i
);
```
The new image does not have a `src` attribute. Check that there is a space after the opening tag's name and/or there are spaces before all attribute names.
```js
assert.isTrue(document.querySelectorAll('section')?.[1]?.lastElementChild?.hasAttribute('src'));
assert.isTrue(document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling?.hasAttribute('src'));
```
The new image should have a `src` value of `https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg`. Make sure the `src` attribute's value is surrounded with quotation marks.

```js
assert.strictEqual(
document.querySelectorAll('section')?.[1]?.lastElementChild?.getAttribute('src'),
document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling?.getAttribute('src'),
'https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg'
);
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,34 @@ And its `alt` attribute value to:
There should be an `img` element right after the closing `</ul>` tag.

```js
assert.equal(document.querySelectorAll('section')[1].lastElementChild.nodeName, 'IMG');
assert.equal(document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling.nodeName, 'IMG');
```

The new image does not have an `alt` attribute. Check that there is a space after the opening tag's name and/or there are spaces before all attribute names.

```js
assert.isTrue(document.querySelectorAll('section')[1].lastElementChild.hasAttribute('alt'));
assert.isTrue(document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling.hasAttribute('alt'));
```

The new image should have an `alt` value of `A slice of lasagna on a plate.` Make sure the `alt` attribute's value is surrounded with quotation marks.

```js
assert.match(
document.querySelectorAll('section')[1]
.lastElementChild.getAttribute('alt')
.replace(/\s+/g, ' '), /^A slice of lasagna on a plate\.?$/i
document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling?.getAttribute('alt')?.replace(/\s+/g, ' '), /^A slice of lasagna on a plate\.?$/i
);
```
The new image does not have a `src` attribute. Check that there is a space after the opening tag's name and/or there are spaces before all attribute names.
```js
assert.isTrue(document.querySelectorAll('section')[1].lastElementChild.hasAttribute('src'));
assert.isTrue(document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling.hasAttribute('src'));
```
The new image should have a `src` value of `https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg`. Make sure the `src` attribute's value is surrounded with quotation marks.

```js
assert.equal(
document.querySelectorAll('section')[1].lastElementChild.getAttribute('src'),
document.querySelectorAll('section')[1].querySelector('ul').nextElementSibling?.getAttribute('src'),
'https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg'
);
```
Expand Down

0 comments on commit 59027fc

Please sign in to comment.