mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore: update steps 20-21 in workshop-magazine to use specific assert methods (#61158)
This commit is contained in:
+6
-6
@@ -14,7 +14,7 @@ Within your `aside` element, create two `img` elements, a `blockquote` element,
|
||||
You should create three `img` elements within your `aside` element.
|
||||
|
||||
```js
|
||||
assert(document.querySelectorAll('aside img')?.length === 3);
|
||||
assert.lengthOf(document.querySelectorAll('aside img'), 3);
|
||||
```
|
||||
|
||||
You should create a `blockquote` element within your `aside` element.
|
||||
@@ -26,17 +26,17 @@ assert.exists(document.querySelector('aside blockquote'));
|
||||
Your `blockquote` element should have a `class` set to `image-quote`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('aside blockquote')?.classList?.contains('image-quote'));
|
||||
assert.isTrue(document.querySelector('aside blockquote')?.classList?.contains('image-quote'));
|
||||
```
|
||||
|
||||
Your new elements should be in the correct order.
|
||||
|
||||
```js
|
||||
const children = document.querySelector('aside')?.children;
|
||||
assert(children?.[0]?.localName === 'img');
|
||||
assert(children?.[1]?.localName === 'img');
|
||||
assert(children?.[2]?.localName === 'blockquote');
|
||||
assert(children?.[3]?.localName === 'img');
|
||||
assert.equal(children?.[0]?.localName, 'img');
|
||||
assert.equal(children?.[1]?.localName, 'img');
|
||||
assert.equal(children?.[2]?.localName, 'blockquote');
|
||||
assert.equal(children?.[3]?.localName, 'img');
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+6
-6
@@ -14,37 +14,37 @@ Within the `.image-wrapper` element, give your first `img` element a `src` of `h
|
||||
Your first `img` element should have a `src` attribute set to `https://cdn.freecodecamp.org/testable-projects-fcc/images/random-quote-machine.png`.
|
||||
|
||||
```js
|
||||
assert(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('src') === 'https://cdn.freecodecamp.org/testable-projects-fcc/images/random-quote-machine.png');
|
||||
assert.equal(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('src'), 'https://cdn.freecodecamp.org/testable-projects-fcc/images/random-quote-machine.png');
|
||||
```
|
||||
|
||||
Your first `img` element should have an `alt` attribute set to `image of the quote machine project`.
|
||||
|
||||
```js
|
||||
assert(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('alt') === 'image of the quote machine project');
|
||||
assert.equal(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('alt'), 'image of the quote machine project');
|
||||
```
|
||||
|
||||
Your first `img` element should have a `class` attribute set to `image-1`.
|
||||
|
||||
```js
|
||||
assert(document.querySelectorAll('.image-wrapper img')?.[0]?.classList?.contains('image-1'));
|
||||
assert.isTrue(document.querySelectorAll('.image-wrapper img')?.[0]?.classList?.contains('image-1'));
|
||||
```
|
||||
|
||||
Your first `img` element should have a `loading` attribute set to `lazy`.
|
||||
|
||||
```js
|
||||
assert(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('loading') === 'lazy');
|
||||
assert.equal(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('loading'), 'lazy');
|
||||
```
|
||||
|
||||
Your first `img` element should have a `width` attribute set to `600`.
|
||||
|
||||
```js
|
||||
assert(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('width') === '600');
|
||||
assert.equal(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('width'), '600');
|
||||
```
|
||||
|
||||
Your first `img` element should have a `height` attribute set to `400`.
|
||||
|
||||
```js
|
||||
assert(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('height') === '400');
|
||||
assert.equal(document.querySelectorAll('.image-wrapper img')?.[0]?.getAttribute('height'), '400');
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
Reference in New Issue
Block a user