fix(curriculum): updated assert method for steps 8-9 of workshop-magazine to use specific asserts (#61110)

This commit is contained in:
Anish Kamath
2025-06-30 02:54:24 -04:00
committed by GitHub
parent ee6b4ab943
commit 502ca94e5a
2 changed files with 11 additions and 11 deletions

View File

@@ -22,31 +22,31 @@ Add five `a` elements within that new `div`, and give them the following `href`
You should create a new `div` element.
```js
assert(document.querySelectorAll('div')?.length === 2);
assert.lengthOf(document.querySelectorAll('div'), 2);
```
Your new `div` element should come after your `.author` element.
```js
assert(document.querySelector('.author')?.nextElementSibling?.localName === 'div');
assert.equal(document.querySelector('.author')?.nextElementSibling?.localName, 'div');
```
Your new `div` element should have the class `social-icons`.
```js
assert(document.querySelector('.author')?.nextElementSibling?.classList?.contains('social-icons'));
assert.isTrue(document.querySelector('.author')?.nextElementSibling?.classList?.contains('social-icons'));
```
Your `.social-icons` element should have five `a` elements.
```js
assert(document.querySelector('.social-icons')?.querySelectorAll('a')?.length === 5);
assert.lengthOf(document.querySelector('.social-icons')?.querySelectorAll('a'), 5);
```
Your first `a` element should have an `href` set to `https://www.facebook.com/freecodecamp`.
```js
assert(document.querySelector('.social-icons')?.querySelectorAll('a')?.[0]?.getAttribute('href')?.includes('https://www.facebook.com/freecodecamp'));
assert.include(document.querySelector('.social-icons')?.querySelectorAll('a')?.[0]?.getAttribute('href'), 'https://www.facebook.com/freecodecamp');
```
Your second `a` element should have an `href` set to `https://twitter.com/freecodecamp`.

View File

@@ -20,7 +20,7 @@ Within each of your new `a` elements, add an `i` element and give them the follo
You should have five `i` elements.
```js
assert(document.querySelectorAll('i')?.length === 5);
assert.lengthOf(document.querySelectorAll('i'), 5);
```
Each `a` element should only have one `i` element.
@@ -51,31 +51,31 @@ iiiii?.forEach(
The first `i` element should have a `class` attribute which includes `fa-facebook-f`.
```js
assert(document.querySelectorAll('i')?.[0]?.classList?.contains('fa-facebook-f'));
assert.isTrue(document.querySelectorAll('i')?.[0]?.classList?.contains('fa-facebook-f'));
```
The second `i` element should have a `class` attribute which includes `fa-twitter`.
```js
assert(document.querySelectorAll('i')?.[1]?.classList?.contains('fa-twitter'));
assert.isTrue(document.querySelectorAll('i')?.[1]?.classList?.contains('fa-twitter'));
```
The third `i` element should have a `class` attribute which includes `fa-instagram`.
```js
assert(document.querySelectorAll('i')?.[2]?.classList?.contains('fa-instagram'));
assert.isTrue(document.querySelectorAll('i')?.[2]?.classList?.contains('fa-instagram'));
```
The fourth `i` element should have a `class` attribute which includes `fa-linkedin-in`.
```js
assert(document.querySelectorAll('i')?.[3]?.classList?.contains('fa-linkedin-in'));
assert.isTrue(document.querySelectorAll('i')?.[3]?.classList?.contains('fa-linkedin-in'));
```
The fifth `i` element should have a `class` attribute which includes `fa-youtube`.
```js
assert(document.querySelectorAll('i')?.[4]?.classList?.contains('fa-youtube'));
assert.isTrue(document.querySelectorAll('i')?.[4]?.classList?.contains('fa-youtube'));
```
# --seed--