mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-19 21:09:51 +08:00
fix: improve tests in travel agency lab (#57743)
This commit is contained in:
parent
077db2d9ff
commit
779bb5a574
@ -142,7 +142,7 @@ assert.strictEqual(
|
||||
You should have two items in your unordered list.
|
||||
|
||||
```js
|
||||
assert.lengthOf(document.querySelectorAll('li'), 2);
|
||||
assert.lengthOf(document.querySelectorAll('p + ul li'), 2);
|
||||
```
|
||||
|
||||
Both your list items should contain an anchor element.
|
||||
@ -205,17 +205,25 @@ Each `figure` element should contain a `figcaption` element as its second child.
|
||||
const figures = document.querySelectorAll('figure');
|
||||
assert.isNotEmpty(figures);
|
||||
for (let figure of figures) {
|
||||
assert.equal(figure.children[1].tagName, 'FIGCAPTION');
|
||||
assert.equal(figure.children[1]?.tagName, 'FIGCAPTION');
|
||||
}
|
||||
```
|
||||
|
||||
Each `figcaption` should contain some text.
|
||||
|
||||
```js
|
||||
const figcaptionEls = document.querySelectorAll('figcaption');
|
||||
assert.isNotEmpty(figcaptionEls);
|
||||
figcaptionEls.forEach((figcaption => assert.isNotEmpty(figcaption.innerText)));
|
||||
```
|
||||
|
||||
Each of the `a` elements that are children of your `figure` elements should contain an image.
|
||||
|
||||
```js
|
||||
const anchors = document.querySelectorAll('figure > a');
|
||||
assert.isNotEmpty(anchors);
|
||||
for (let anchor of anchors) {
|
||||
assert.equal(anchor.children[0].tagName, 'IMG');
|
||||
assert.equal(anchor.children[0]?.tagName, 'IMG');
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user