fix(curriculum) Fixed test to only allow valid JSX comments for Add Comments In JSX challenge (#35320)

* fix: only allow valid jsx comments in div elem

* fix: allow blank comment and removed assert msgs
pull/35631/head
Randell Dawson 2019-03-18 22:00:12 -07:00 committed by Manish Giri
parent 824d459182
commit 4d1d89b1c7
1 changed files with 7 additions and 6 deletions

View File

@ -22,14 +22,15 @@ The code editor has a JSX element similar to what you created in the last challe
```yml ```yml
tests: tests:
- text: The constant <code>JSX</code> should return a <code>div</code> element. - text: The constant <code>JSX</code> should return a <code>div</code> element.
testString: assert(JSX.type === 'div', 'The constant <code>JSX</code> should return a <code>div</code> element.'); testString: assert(JSX.type === 'div');
- text: The <code>div</code> should contain an <code>h1</code> tag as the first element. - text: The <code>div</code> should contain an <code>h1</code> tag as the first element.
testString: assert(JSX.props.children[0].type === 'h1', 'The <code>div</code> should contain an <code>h1</code> tag as the first element.'); testString: assert(JSX.props.children[0].type === 'h1');
- text: The <code>div</code> should contain a <code>p</code> tag as the second element. - text: The <code>div</code> should contain a <code>p</code> tag as the second element.
testString: assert(JSX.props.children[1].type === 'p', 'The <code>div</code> should contain a <code>p</code> tag as the second element.'); testString: assert(JSX.props.children[1].type === 'p');
- text: The <code>JSX</code> should include a comment. - text: The existing <code>h1</code> and <code>p</code> elements should not be modified.
testString: getUserInput => assert(getUserInput('index').includes('/*') && getUserInput('index').includes('*/'), 'The <code>JSX</code> should include a comment.'); testString: assert(JSX.props.children[0].props.children === 'This is a block of JSX' && JSX.props.children[1].props.children === 'Here\'s a subtitle');
- text: The <code>JSX</code> should use valid comment syntax.
testString: assert(/<div>[\s\S]*{\s*\/\*[\s\S]*\*\/\s*}[\s\S]*<\/div>/.test(code));
``` ```
</section> </section>