Skip to content

Commit

Permalink
fix(curriculum): Made tests not accept invalid HTML (#35774)
Browse files Browse the repository at this point in the history
* fix: made tests stricter

* fix: simplify text

Co-Authored-By: RandellDawson <5313213+RandellDawson@users.noreply.github.com>
  • Loading branch information
RandellDawson authored and thecodingaviator committed Apr 10, 2019
1 parent 5ac765c commit 42bc9fa
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,'')));

```

Expand Down

0 comments on commit 42bc9fa

Please sign in to comment.