-
Notifications
You must be signed in to change notification settings - Fork 2
/
superagent-mock-config.js
47 lines (44 loc) · 1.11 KB
/
superagent-mock-config.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
module.exports = [
{
/**
* regular expression of URL
*/
pattern: '(.*)',
/**
* returns the data
*
* @param match array Result of the resolution of the regular expression
* @param params object sent by 'send' function
* @param headers object set by 'set' function
* @param context object the context of running the fixtures function
*/
fixtures: function (match, params, headers, context) {
return {
match, params, headers, context
}
},
/**
* returns the result of the GET request
*
* @param match array Result of the resolution of the regular expression
* @param data mixed Data returns by `fixtures` attribute
*/
get: function (match, data) {
return {
body: data
};
},
/**
* returns the result of the POST request
*
* @param match array Result of the resolution of the regular expression
* @param data mixed Data returns by `fixtures` attribute
*/
post: function (match, data) {
return {
status: 200,
body: data
};
}
}
];