UNPKG

1.17 kBJavaScriptView Raw
1var BB = require('bluebird');
2
3function Request() {
4 this.getAsync = function(options, callback) {
5 if (options.errorTest) {
6 return BB.reject({
7 statuscode: 403,
8 statusdesc: 'Test',
9 errormessage: 'Test Message'
10 });
11 }
12
13 if (options.successTest) {
14 return BB.resolve([
15 JSON.stringify({
16 "sample": "response"
17 }),
18 JSON.stringify({
19 "sample": "body"
20 })
21 ])
22 }
23 };
24
25 this.postAsync = function(options, callback) {
26 if (options.errorTest) {
27 return BB.reject({
28 statuscode: 403,
29 statusdesc: 'Forbidden',
30 errormessage: 'No free checks available'
31 });
32 }
33
34 if (options.successTest) {
35 return BB.resolve([
36 JSON.stringify({
37 "body": {
38 "check": {
39 "id": 138631,
40 "name": "My new HTTP check"
41 }
42 }
43 }),
44 JSON.stringify({
45 "check": {
46 "id": 138631,
47 "name": "My new HTTP check"
48 }
49 })
50 ]);
51 }
52 }
53}
54
55module.exports = exports = function MockRequestFactory() {
56 return new Request();
57}
\No newline at end of file