mirror of
https://github.com/LukasKanka/api_test.git
synced 2026-11-11 06:34:36 +01:00
newTests
This commit is contained in:
1 parent
4ef7925897
commit
5eccc82603
3 files changed
+83
-3
No files matched your search
@@ -0,0 +1,34 @@
|
||||
info:
|
||||
name: Get specific spell
|
||||
type: http
|
||||
seq: 3
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: http://localhost:3000/spells/5b74ed6d3228320021ab622f
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: tests
|
||||
code: |-
|
||||
const expectedSpell={
|
||||
"id": "5b74ed6d3228320021ab622f",
|
||||
"spell": "Alohomora",
|
||||
"type": "Charm",
|
||||
"effect": "opens locked objects",
|
||||
"isUnforgivable": false
|
||||
}
|
||||
|
||||
test("It should return the correct spell", function(){
|
||||
expect(res.getBody()).to.deep.equal(expectedSpell)
|
||||
})
|
||||
|
||||
//deep porovná vše 1:1
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
forwardAuthorizationHeader: false
|
||||
@@ -0,0 +1,41 @@
|
||||
info:
|
||||
name: Get spells
|
||||
type: http
|
||||
seq: 2
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: http://localhost:3000/spells?type=Curse&limit=2
|
||||
params:
|
||||
- name: type
|
||||
value: Curse
|
||||
type: query
|
||||
- name: limit
|
||||
value: "2"
|
||||
type: query
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: tests
|
||||
code: |-
|
||||
const body = res.getBody()
|
||||
|
||||
// Ověřím že se mi vrací Curse z (Query Params)
|
||||
test("Each spell should have type Curse", function(){
|
||||
body.forEach(spellMember => expect(spellMember.type).to.eql("Curse"))
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Ověřím že se mi vrací pouze 2 záznamy (limit)
|
||||
test("Response should contain exactly 2 spells", function(){
|
||||
expect(body).has.length(2)
|
||||
});
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
forwardAuthorizationHeader: false
|
||||
@@ -24,15 +24,20 @@ runtime:
|
||||
})
|
||||
|
||||
test("Message from sorting hat should not be empty", function(){
|
||||
expect(res.getBody().sortingHatSays).not.to.be.empty
|
||||
expect(body.sortingHatSays).not.to.be.empty
|
||||
})
|
||||
|
||||
test("Message from house should not be empty", function(){
|
||||
expect(res.getBody().house).not.to.be.empty
|
||||
expect(body.house).not.to.be.empty
|
||||
})
|
||||
|
||||
test("House is one of Gryffindor, Slytherin, Ravenclaw, Hufflepuff",function(){
|
||||
expect(res.getBody().house).is.oneOf(["Gryffindor", "Slytherin", "Ravenclaw", "Hufflepuff" ])
|
||||
expect(body.house).is.oneOf(["Gryffindor", "Slytherin", "Ravenclaw", "Hufflepuff" ])
|
||||
})
|
||||
|
||||
// Ověřím odpověď do 550 ms
|
||||
test("Response time is less than 550 ms", function(){
|
||||
expect(res.responseTime).to.be.below(550)
|
||||
})
|
||||
|
||||
settings:
|
||||
|
||||
Reference in new issue
Block a user