@@ -16,17 +16,17 @@ chai.use(sinonChai);
16
16
var jobs ;
17
17
describe ( '#Queue service' , function ( ) {
18
18
before ( function ( ) { /* jslint ignore:line */
19
- queue . testMode . enter ( ) ;
20
- jobs = require ( '../../services/queue/jobs' ) ;
21
- } ) ;
19
+ queue . testMode . enter ( ) ;
20
+ jobs = require ( '../../services/queue/jobs' ) ;
21
+ } ) ;
22
22
23
23
afterEach ( function ( ) { /* jslint ignore:line */
24
- queue . testMode . clear ( ) ;
25
- } ) ;
24
+ queue . testMode . clear ( ) ;
25
+ } ) ;
26
26
27
27
after ( function ( ) { /* jslint ignore:line */
28
- queue . testMode . exit ( ) ;
29
- } ) ;
28
+ queue . testMode . exit ( ) ;
29
+ } ) ;
30
30
31
31
it ( 'should return an object' , function ( done ) {
32
32
queue . should . be . an ( 'object' ) ;
@@ -37,12 +37,12 @@ describe('#Queue service', function(){
37
37
} ) ;
38
38
39
39
it ( 'should pass basic smoke test' , function ( ) {
40
- queue . createJob ( 'myJob' , 'foo' ) . save ( ) ;
41
- queue . createJob ( 'anotherJob' , { baz : 'bip' } ) . save ( ) ;
42
- queue . testMode . jobs . length . should . equal ( 2 ) ;
43
- queue . testMode . jobs [ 0 ] . type . should . equal ( 'myJob' ) ;
44
- queue . testMode . jobs [ 0 ] . data . should . equal ( 'foo' ) ;
45
- } ) ;
40
+ queue . createJob ( 'myJob' , 'foo' ) . save ( ) ;
41
+ queue . createJob ( 'anotherJob' , { baz : 'bip' } ) . save ( ) ;
42
+ queue . testMode . jobs . length . should . equal ( 2 ) ;
43
+ queue . testMode . jobs [ 0 ] . type . should . equal ( 'myJob' ) ;
44
+ queue . testMode . jobs [ 0 ] . data . should . equal ( 'foo' ) ;
45
+ } ) ;
46
46
47
47
it ( 'should load processes' , function ( ) {
48
48
var process = require ( '../../services/queue/workers' ) ;
@@ -78,33 +78,150 @@ describe('#Queue service', function(){
78
78
jobs . updateRequestLog ( myrequestlog , done ) ;
79
79
} ) ;
80
80
it ( 'should run createSearchTags successfully for saving data' , function ( done ) {
81
- var myrequestlog = {
82
- RequestId : 'gdfd6563' ,
83
- ipAddress : '192.168.90.9' ,
84
- url : 'http://google.com' ,
85
- method : 'POST' ,
86
- body : { name : 'femi' } ,
87
- createdAt : new Date ( )
88
- } ;
81
+ var myrequestlog = {
82
+ RequestId : 'gdfd6563' ,
83
+ ipAddress : '192.168.90.9' ,
84
+ url : 'http://google.com' ,
85
+ method : 'POST' ,
86
+ body : { name : 'femi' } ,
87
+ createdAt : new Date ( )
88
+ } ;
89
89
90
- myrequestlog . model = 'RequestLogs' ;
91
- jobs . createSearchTags ( myrequestlog , done ) ;
92
- } ) ;
90
+ myrequestlog . model = 'RequestLogs' ;
91
+ jobs . createSearchTags ( myrequestlog , done ) ;
92
+ } ) ;
93
93
94
94
it ( 'should run createSearchTags successfully for updating data' , function ( done ) {
95
- var myrequestlog = {
96
- RequestId : 'gdfd6563' ,
97
- ipAddress : '192.168.90.9' ,
98
- url : 'http://google.com' ,
99
- method : 'POST' ,
100
- body : { name : 'femi' } ,
101
- createdAt : new Date ( )
102
- } ;
95
+ var myrequestlog = {
96
+ RequestId : 'gdfd6563' ,
97
+ ipAddress : '192.168.90.9' ,
98
+ url : 'http://google.com' ,
99
+ method : 'POST' ,
100
+ body : { name : 'femi' } ,
101
+ createdAt : new Date ( )
102
+ } ;
103
103
104
- myrequestlog . model = 'RequestLogs' ;
105
- myrequestlog . update = true ;
106
- jobs . createSearchTags ( myrequestlog , done ) ;
107
- } ) ;
104
+ myrequestlog . model = 'RequestLogs' ;
105
+ myrequestlog . update = true ;
106
+ jobs . createSearchTags ( myrequestlog , done ) ;
107
+ } ) ;
108
+
109
+ it ( 'should run saveToTrash successfully for backing up data' , function ( done ) {
110
+ var backup = {
111
+ data : {
112
+ _id : '789878' ,
113
+ name : 'foo'
114
+ }
115
+ } ;
116
+
117
+ jobs . saveToTrash ( backup , done ) ;
118
+ } ) ;
119
+
120
+ it ( 'should run sendWebhook successfully for sending realtime HTTP notifications' , function ( done ) {
121
+ var data = {
122
+ url : 'https://httpbin.org/anything' ,
123
+ secure : false , // true or false
124
+ data : {
125
+ someData : 'this' ,
126
+ someOtherData : 'and this'
127
+ }
128
+ } ;
129
+
130
+ jobs . sendWebhook ( data , done ) ;
131
+ } ) ;
132
+
133
+ it ( 'should run sendWebhook successfully for sending realtime HTTP notifications securely' , function ( done ) {
134
+ var data = {
135
+ url : 'https://httpbin.org/anything' ,
136
+ secure : true , // true or false
137
+ data : {
138
+ someData : 'this' ,
139
+ someOtherData : 'and this'
140
+ }
141
+ } ;
142
+
143
+ jobs . sendWebhook ( data , done ) ;
144
+ } ) ;
145
+
146
+ it ( 'should run sendHTTPRequest successfully for calling web services with POST method' , function ( done ) {
147
+ var data = {
148
+ url : 'https://httpbin.org/anything' ,
149
+ method : 'POST' , // or any http method
150
+ headers : {
151
+ 'User-Agent' : 'Femi'
152
+ } ,
153
+ data : {
154
+ someData : 'this' ,
155
+ someOtherData : 'and this'
156
+ }
157
+ } ;
158
+
159
+ jobs . sendHTTPRequest ( data , done ) ;
160
+ } ) ;
161
+
162
+ it ( 'should run sendHTTPRequest successfully for calling web services with GET method' , function ( done ) {
163
+ var data = {
164
+ url : 'https://httpbin.org/anything' ,
165
+ method : 'GET' , // or any http method
166
+ headers : {
167
+ 'User-Agent' : 'Femi'
168
+ } ,
169
+ data : {
170
+ someData : 'this' ,
171
+ someOtherData : 'and this'
172
+ }
173
+ } ;
174
+
175
+ jobs . sendHTTPRequest ( data , done ) ;
176
+ } ) ;
177
+
178
+ it ( 'should run sendHTTPRequest successfully for calling web services with PUT method' , function ( done ) {
179
+ var data = {
180
+ url : 'https://httpbin.org/anything' ,
181
+ method : 'PUT' , // or any http method
182
+ headers : {
183
+ 'User-Agent' : 'Femi'
184
+ } ,
185
+ data : {
186
+ someData : 'this' ,
187
+ someOtherData : 'and this'
188
+ }
189
+ } ;
190
+
191
+ jobs . sendHTTPRequest ( data , done ) ;
192
+ } ) ;
193
+
194
+ it ( 'should run sendHTTPRequest successfully for calling web services with DELETE method' , function ( done ) {
195
+ var data = {
196
+ url : 'https://httpbin.org/anything' ,
197
+ method : 'DELETE' , // or any http method
198
+ headers : {
199
+ 'User-Agent' : 'Femi'
200
+ } ,
201
+ data : {
202
+ someData : 'this' ,
203
+ someOtherData : 'and this'
204
+ }
205
+ } ;
206
+
207
+ jobs . sendHTTPRequest ( data , done ) ;
208
+ } ) ;
209
+
210
+ it ( 'should run sendHTTPRequest successfully for calling web services with PATCH method' , function ( done ) {
211
+ var data = {
212
+ url : 'https://httpbin.org/anything' ,
213
+ method : 'PATCH' , // or any http method
214
+ headers : {
215
+ 'User-Agent' : 'Femi'
216
+ } ,
217
+ data : {
218
+ someData : 'this' ,
219
+ someOtherData : 'and this'
220
+ }
221
+ } ;
222
+
223
+ jobs . sendHTTPRequest ( data , done ) ;
224
+ } ) ;
108
225
109
226
} ) ;
110
227
} ) ;
0 commit comments