Skip to content

Commit c052126

Browse files
authored
Update part5d.md
1 parent f14b997 commit c052126

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/content/5/en/part5d.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,9 +1136,12 @@ Make a test for ensuring that the user who created a blog can delete it.
11361136
11371137
Make a test which checks that the blogs are ordered according to likes with the blog with the most likes being first.
11381138
1139-
This exercise is quite a bit trickier than the previous ones. One solution is to find all of the blogs and then compare them in the callback function of a [then](https://docs.cypress.io/api/commands/then.html#DOM-element) command.
1139+
This exercise is quite a bit trickier than the previous ones. One solution is to add a certain class for the element which wraps the blog's content and use the [eq](https://docs.cypress.io/api/commands/eq#Syntax)-method to get the blog element in a specific index:
1140+
1141+
```js
1142+
cy.get('.blog').eq(0).should('contain', 'The title of the first blog')
1143+
cy.get('.blog').eq(1).should('contain', 'The title of the second blog')
11401144

1141-
If you use a `map` on a selection from cypress, mind that it uses a [jQuery map](https://api.jquery.com/map/#map-callback). This means that the arguments of the callback function are swapped from an [ordinary JavaScript map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) (i.e. you use `(i, el) => {...}` instead of `(el, i) => {...}`).
11421145

11431146
Note that you might end up having problems if you click a like button many times in row. It might be that cypress does the clicking so fast that it does not have time to update the app state in between the clicks. One remedy for this is to wait for the number of likes to update in between all clicks.
11441147

0 commit comments

Comments
 (0)