fix(curriculum): use DOM for link element tests (#47208)

* fix(curriculum): use DOM for link element tests

* fix: revert back to regex for link element location test
pull/47233/head
Lasse Jørgensen 2022-08-09 22:02:16 +02:00 committed by GitHub
parent 35ae1439f3
commit 50e6afcc14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -95,25 +95,28 @@ assert.isAtLeast(title?.textContent?.length, 1);
Your code should have a `link` element.
```js
assert(/<link/.test(code))
assert.exists(document.querySelector('link'));
```
Your `link` element should be within your `head` element.
```js
assert(code.match(/<head>[\w\W\s]*<link[\w\W\s]*\/>[\w\W\s]*<\/head>/i))
assert(code.match(/<head>[\w\W\s]*<link[\w\W\s]*\/?>[\w\W\s]*<\/head>/i));
```
Your `link` element should have a `rel` attribute with the value `stylesheet`.
```js
assert.match(code, /<link[\s\S]*?rel=('|"|`)stylesheet\1/)
const link_element = document.querySelector('link');
const rel = link_element.getAttribute("rel");
assert.equal(rel, "stylesheet");
```
Your `link` element should have an `href` attribute with the value `styles.css`.
```js
assert.match(code, /<link[\s\S]*?href=('|"|`)(\.\/)?styles\.css\1/)
const link = document.querySelector('link');
assert.equal(link.dataset.href, "styles.css");
```
# --seed--