-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstar_wars_test.js
43 lines (39 loc) · 1.14 KB
/
star_wars_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const joi = require('joi');
Feature('Star Wars');
const characterSchema = joi.object({
films: joi.array(),
gender: joi.string(),
hair_color: joi.string(),
height: joi.string(),
mass: joi.string(),
name: joi.string(),
skin_color: joi.string(),
created: joi.date()
}).unknown();
Scenario('get all characters', ({ I }) => {
I.sendGetRequest('/people');
I.seeResponseCodeIsSuccessful();
I.seeResponseContainsKeys(['count', 'results']);
I.seeResponseMatchesJsonSchema(joi => {
return joi.object({
count: joi.number(),
previous: joi.string().uri().allow(null),
next: joi.string().uri().optional().allow(null),
results: joi.array().items(characterSchema),
});
})
I.seeResponseValidByCallback(({ expect, data }) => {
expect(data.results.length).to.be.gte(10);
});
});
Scenario('check the first character', ({ I }) => {
I.sendGetRequest('/people/1');
I.seeResponseCodeIsSuccessful();
I.seeResponseContainsKeys(['name', 'films']);
I.seeResponseMatchesJsonSchema(characterSchema);
I.seeResponseContainsJson({
name: 'Luke Skywalker',
birth_year: "19BBY",
gender: "male",
})
});