fix(curriculum): Made tests not accept invalid HTML (#35774)
* fix: made tests stricter * fix: simplify text Co-Authored-By: RandellDawson <5313213+RandellDawson@users.noreply.github.com>
This commit is contained in:
parent
5ac765c56a
commit
42bc9fa9b6
@ -33,11 +33,11 @@ Finally don't forget to give your image an <code>alt</code> text.
|
||||
```yml
|
||||
tests:
|
||||
- text: Your page should have an image element.
|
||||
testString: assert($("img").length > 0, 'Your page should have an image element.');
|
||||
testString: assert($("img").length);
|
||||
- text: Your image should have a <code>src</code> attribute that points to the kitten image.
|
||||
testString: assert(new RegExp("\/\/bit.ly\/fcc-relaxing-cat|\/\/s3.amazonaws.com\/freecodecamp\/relaxing-cat.jpg", "gi").test($("img").attr("src")), 'Your image should have a <code>src</code> attribute that points to the kitten image.');
|
||||
- text: Your image element <strong>must</strong> have an <code>alt</code> attribute.
|
||||
testString: assert(code.match(/alt\s*?=\s*?(\"|\').*(\"|\')/), 'Your image element <strong>must</strong> have an <code>alt</code> attribute.');
|
||||
testString: assert(/^https:\/\/bit\.ly\/fcc-relaxing-cat$/i.test($("img").attr("src")));
|
||||
- text: Your image element's <code>alt</code> attribute <strong>must</strong> not be empty.
|
||||
testString: assert($("img").attr("alt") && $("img").attr("alt").length && /<img\S*alt=(['"])(?!\1|>)\S+\1\S*\/?>/.test(code.replace(/\s/g,'')));
|
||||
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user