Skip to content

Commit df48661

Browse files
authored
Updated GraphQL swapi test with Lodash
1 parent b6d57fb commit df48661

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

SWAPI.postman_collection.json

+12-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
"var jsonData = pm.response.json();",
3131
"pm.test(\"Has correct schema\", function() {",
3232
" pm.expect(jsonData.data.allFilms.films).to.be.a(\"array\");",
33-
" for(var i=0; i<jsonData.data.allFilms.films.length; i++){",
34-
" pm.expect(jsonData.data.allFilms.films[i].id).to.be.a(\"string\");",
35-
" pm.expect(jsonData.data.allFilms.films[i].title).to.be.a(\"string\");",
36-
" pm.expect(jsonData.data.allFilms.films[i].episodeID).to.be.a(\"number\");",
37-
" }",
33+
" _.each(jsonData.data.allFilms.films, (film) => {",
34+
" pm.expect(film.id).to.be.a(\"string\", \"Film ID not string.\");",
35+
" pm.expect(film.title).to.be.a(\"string\", \"Film Title not string.\");",
36+
" pm.expect(film.episodeID).to.be.a(\"number\", \"Film Episode ID not number.\");",
37+
" })",
3838
"});"
3939
],
4040
"type": "text/javascript"
@@ -44,6 +44,13 @@
4444
"request": {
4545
"method": "POST",
4646
"header": [],
47+
"body": {
48+
"mode": "graphql",
49+
"graphql": {
50+
"query": "query{\n allFilms\n {\n films {\n id\n title\n episodeID\n }\n }\n}",
51+
"variables": ""
52+
}
53+
},
4754
"url": {
4855
"raw": "https://swapi.apis.guru/",
4956
"protocol": "https",

0 commit comments

Comments
 (0)