feat(client, learn): add helper functions for common validation operations (#38605)

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
This commit is contained in:
Hassaan Pasha
2020-09-17 19:08:01 +05:00
committed by GitHub
parent aecbc28798
commit 80438cac3e
54 changed files with 326 additions and 157 deletions

View File

@ -38,7 +38,7 @@ tests:
- text: Your image should have a <code>src</code> attribute that points to the kitten image.
testString: assert(/^https:\/\/bit\.ly\/fcc-relaxing-cat$/i.test($("img").attr("src")));
- text: Your image element's <code>alt</code> attribute should not be empty.
testString: assert($("img").attr("alt") && $("img").attr("alt").length && /<img\S*alt=(['"])(?!\1|>)\S+\1\S*\/?>/.test(code.replace(/\s/g,'')));
testString: assert($("img").attr("alt") && $("img").attr("alt").length && /<img\S*alt=(['"])(?!\1|>)\S+\1\S*\/?>/.test(__helpers.removeWhiteSpace(code)));
```

View File

@ -52,9 +52,9 @@ tests:
- text: Your <code>li</code> element should have a closing tag.
testString: assert(code.match(/<\/li>/g) && code.match(/<li>/g) && code.match(/<\/li>/g).length === code.match(/<li>/g).length);
- text: The <code>li</code> elements in your unordered list should not be empty.
testString: $('ul li').each((i, val) => assert(val.textContent.replace(/\s/g, '')));
testString: $('ul li').each((i, val) => assert(__helpers.removeWhiteSpace(val.textContent)));
- text: The <code>li</code> elements in your ordered list should not be empty.
testString: $('ol li').each((i, val) => assert(!!val.textContent.replace(/\s/g, '')));
testString: $('ol li').each((i, val) => assert(!!__helpers.removeWhiteSpace(val.textContent)));
```