This commit is contained in:
kankys committed 2026-09-15 20:50:51 +02:00
1 parent 4b7af6ee7a
commit 2e185b47ef
12 files changed
+213 -6

No files matched your search

@@ -0,0 +1,45 @@
info:
name: Get specific spell schama
type: http
seq: 4
http:
method: GET
url: http://localhost:3000/spells/5b74ed6d3228320021ab622f
auth: inherit
runtime:
scripts:
- type: tests
code: |-
const schema = {
"type": "object",
"required": ["id", "spell", "type", "effect", "isUnforgivable"],
"properties": {
"id":{
"type": "string",
"minLength": 20, // id musí být minimálně 20 znaků dlouhý
},
"isUnforgivable":{
"type": "boolean",
},
"type":{
"enum":["Spell","Charm", "Curse", "Enchantment", "Jinx", "Hex"]
}, // kontroluje zda-li je typ jedním z povolených (enum) typů
"spell":{
"pattern": "^[A-Z].+" // musí začínat velkým písmenem
}
}
}
// Otestuji zda-li se odpověď shoduje s očekávaným schématem
test("Response should match schema", function(){
expect(res.getBody()).to.have.jsonSchema(schema)
})
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
forwardAuthorizationHeader: false
@@ -0,0 +1,34 @@
info:
name: Get specific spell
type: http
seq: 1
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
+41
View File
@@ -0,0 +1,41 @@
info:
name: Get spells
type: http
seq: 3
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
+48
View File
@@ -0,0 +1,48 @@
info:
name: ShortingHat
type: http
seq: 2
http:
method: GET
url: http://localhost:3000/sortingHat
auth: inherit
runtime:
scripts:
- type: tests
code: |-
const status = res.getStatus()
const body = res.getBody()
test("Status code is 200", function() {
expect(status).to.equal(200);
});
test("Response should contain sortingHat key", function(){
expect(body).to.contain.key("sortingHatSays")
})
test("Message from sorting hat should not be empty", function(){
expect(body.sortingHatSays).not.to.be.empty
})
test("Message from house should not be empty", function(){
expect(body.house).not.to.be.empty
})
test("House is one of Gryffindor, Slytherin, Ravenclaw, Hufflepuff",function(){
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:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
forwardAuthorizationHeader: false
+7
View File
@@ -0,0 +1,7 @@
info:
name: GET
type: folder
seq: 1
request:
auth: inherit