Skip to content

Commit c377346

Browse files
authored
fix(curriculum): update tests, remove self-closing (freeCodeCamp#55544)
1 parent 543e804 commit c377346

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

curriculum/challenges/english/14-responsive-web-design-22/learn-css-grid-by-building-a-magazine/614385513d91ae5c251c2052.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,78 @@ Your font stylesheet will load three separate fonts: `Anton`, `Baskervville`, an
1313

1414
# --hints--
1515

16-
Your code should have three self-closing `link` elements.
16+
Your code should have three `link` elements.
1717

1818
```js
19-
assert(document.querySelectorAll('link').length === 3);
19+
assert.strictEqual(document.querySelectorAll('link')?.length, 3);
2020
```
2121
22-
Your `link` element should be within your `head` element.
22+
Your `link` elements should be inside your `head` element.
2323
2424
```js
25-
assert(document.querySelectorAll('head > link').length === 3);
25+
const headContentRegex = /(?<=<head\s*>)(?:.|\s*)*?(?=<\/head\s*>)/;
26+
const headElementContent = code.match(headContentRegex);
27+
28+
const headElement = document.createElement("head");
29+
headElement.innerHTML = headElementContent;
30+
assert.strictEqual(headElement.querySelectorAll('link')?.length, 3);
2631
```
2732
2833
Your three `link` elements should have a `rel` attribute with the value `stylesheet`.
2934
3035
```js
3136
const links = [...document.querySelectorAll('link')];
32-
assert(links.every(link => link.getAttribute('rel') === 'stylesheet'));
37+
assert.isTrue(links.every(link => link.getAttribute('rel') === 'stylesheet'));
3338
```
3439
3540
One of your link elements should have the `href` set to `https://fonts.googleapis.com/css?family=Anton%7CBaskervville%7CRaleway&display=swap`.
3641

3742
```js
3843
const links = [...document.querySelectorAll('link')];
39-
assert(links.find(link => link.getAttribute('href') === 'https://fonts.googleapis.com/css?family=Anton%7CBaskervville%7CRaleway&display=swap'));
44+
assert.exists(links.find(link => link.getAttribute('href') === 'https://fonts.googleapis.com/css?family=Anton%7CBaskervville%7CRaleway&display=swap'));
4045
```
4146

4247
One of your link elements should have the `href` set to `https://use.fontawesome.com/releases/v5.8.2/css/all.css`.
4348

4449
```js
4550
const links = [...document.querySelectorAll('link')];
46-
assert(links.find(link => link.getAttribute('href') === 'https://use.fontawesome.com/releases/v5.8.2/css/all.css'));
51+
assert.exists(links.find(link => link.getAttribute('href') === 'https://use.fontawesome.com/releases/v5.8.2/css/all.css'));
4752
```
4853

49-
One of your `link` elements should have an `href` attribute with the value `styles.css`.
54+
One of your `link` elements should have the `href` set to `styles.css`.
5055

5156
```js
52-
assert.match(code, /<link[\s\S]*?href\s*=\s*('|"|`)(\.\/)?styles\.css\1/)
57+
const styleElement = document.querySelector('[data-href]');
58+
assert.isNotNull(styleElement);
59+
assert.strictEqual(styleElement?.getAttribute('data-href'), 'styles.css');
5360
```
5461

5562
Your code should have a `title` element.
5663

5764
```js
5865
const title = document.querySelector('title');
59-
assert.exists(title);
66+
assert.isNotNull(title);
6067
```
6168

62-
Your project should have a title of `Magazine`.
69+
Your code should have one `title` element.
6370

6471
```js
65-
const title = document.querySelector('title');
66-
assert.equal(title?.text?.trim()?.toLowerCase(), 'magazine')
72+
const title = document.querySelectorAll('title');
73+
assert.strictEqual(title?.length, 1);
74+
```
75+
76+
Your `title` element should be inside your `head` element.
77+
78+
```js
79+
const headContentRegex = /(?<=<head\s*>)(?:.|\s*)*?(?=<\/head\s*>)/;
80+
const headElementContent = code.match(headContentRegex);
81+
82+
const headElement = document.createElement("head");
83+
headElement.innerHTML = headElementContent;
84+
assert.isNotNull(headElement.querySelector('title'));
6785
```
6886

69-
Remember, the casing and spelling matter for the title.
87+
Your project should have a title of `Magazine`. Remember, the casing and spelling matter for the title.
7088

7189
```js
7290
const title = document.querySelector('title');

0 commit comments

Comments
 (0)