fix(curriculum): head content test (#56257)

This commit is contained in:
Lasse Jørgensen
2024-09-30 22:07:26 +02:00
committed by GitHub
parent 03fa03c66e
commit 0f5cb9d3cd
@@ -36,11 +36,15 @@ const target = meta?.find(m => m?.getAttribute('name')?.toLowerCase()?.replace(/
assert.exists(target);
```
Your new `meta` element should be inside the `head` element.
Your two `meta` elements should be inside the `head` element.
```js
const metaElementRegex = /<head\s*>(?:.|\r|\n)*?<meta\s+name\s*=\s*('|"|`)\s*viewport\s*\1\s+content\s*=\s*\1\s*width\s*=\s*device-width\s*,\s*initial-scale\s*=\s*1(?:\.0)?\s*\1(?:.|\r|\n)*?<\/head\s*>/i;
assert.match(code, metaElementRegex);
const headContentRegex = /(?<=<head\s*>)[\S|\s]*(?=<\/head\s*>)/;
const headElementContent = code.match(headContentRegex);
const headElement = document.createElement("head");
headElement.innerHTML = headElementContent;
assert.strictEqual(headElement.querySelectorAll('meta').length, 2);
```
# --seed--