-
Notifications
You must be signed in to change notification settings - Fork 12
/
swopr-responses.example.js
81 lines (79 loc) · 1.42 KB
/
swopr-responses.example.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const users = [
{
id: '1',
name: 'User 1'
},
{
id: '2',
name: 'User 2'
},
{
id: '3',
name: 'User 3'
}
];
const getUserById = ({id}) => users.find((user) => user.id === id);
/* eslint-disable no-unused-vars */
const responses = [
{
url: 'https://api.example.com/json',
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
body: {
message: 'a json response'
}
},
{
url: 'https://api.example.com/users/:id',
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
body: params => getUserById(params),
},
{
url: 'https://api.example.com/text',
method: 'GET',
body: 'plain text body'
},
{
url: 'https://api.example.com/pdf',
method: 'GET',
headers: {
'Content-Type': 'application/pdf'
},
file: 'demo/example.pdf'
},
{
url: 'https://api.example.com/post',
method: 'POST',
status: 201,
statusText: 'Created',
headers: {
'Content-Type': 'application/json'
},
body: {
message: 'created'
}
},
{
url: 'https://api.example.com/notfound',
method: 'GET',
status: 404,
statusText: 'Not found',
headers: {
'Content-Type': 'application/json'
},
body: {
message: 'Not found'
}
},
{
url: 'https://localhost/*',
method: 'GET',
status: 302,
redirectUrl: 'http://localhost:8080/$1'
}
];