@athenna/http 3.2.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Commands/MakeControllerCommand.d.ts +12 -0
- package/build/Commands/MakeControllerCommand.js +29 -2
- package/build/Commands/MakeInterceptorCommand.d.ts +12 -0
- package/build/Commands/MakeInterceptorCommand.js +29 -2
- package/build/Commands/MakeMiddlewareCommand.d.ts +12 -0
- package/build/Commands/MakeMiddlewareCommand.js +29 -2
- package/build/Commands/MakeTerminatorCommand.d.ts +12 -0
- package/build/Commands/MakeTerminatorCommand.js +29 -2
- package/build/Commands/RouteListCommand.d.ts +8 -1
- package/build/Commands/RouteListCommand.js +17 -3
- package/build/Testing/Plugins/Request/TestRequest.d.ts +98 -0
- package/build/Testing/Plugins/Request/TestRequest.js +114 -0
- package/build/Testing/Plugins/Request/TestResponse.d.ts +355 -0
- package/build/Testing/Plugins/Request/TestResponse.js +400 -0
- package/build/Testing/Plugins/index.d.ts +20 -0
- package/build/Testing/Plugins/index.js +19 -0
- package/package.json +11 -5
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @athenna/http
|
|
3
|
+
*
|
|
4
|
+
* (c) João Lenon <lenon@athenna.io>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
import { Assert } from '@japa/assert';
|
|
10
|
+
import { Response } from 'light-my-request';
|
|
11
|
+
export declare class TestResponse {
|
|
12
|
+
/**
|
|
13
|
+
* Japa assert class instance.
|
|
14
|
+
*/
|
|
15
|
+
assert: Assert;
|
|
16
|
+
/**
|
|
17
|
+
* Light my request response object.
|
|
18
|
+
*/
|
|
19
|
+
response: Response;
|
|
20
|
+
constructor(assert: Assert, response: Response);
|
|
21
|
+
/**
|
|
22
|
+
* Assert the status code of the response.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```js
|
|
26
|
+
* response.assertStatusCode(200)
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
assertStatusCode(statusCode: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Assert the status code is not the same of the response.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```js
|
|
35
|
+
* response.assertIsNotStatusCode(200)
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
assertIsNotStatusCode(statusCode: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Assert body (array or object) to contain a subset of the expected value.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```js
|
|
44
|
+
* const body = { id: 1, name: 'post 1' }
|
|
45
|
+
*
|
|
46
|
+
* response.assertBodyContains({ id: 1 }) // passes
|
|
47
|
+
* ```
|
|
48
|
+
* @example
|
|
49
|
+
* ```js
|
|
50
|
+
* const body = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
51
|
+
*
|
|
52
|
+
* response.assertBodyContains([{ id: 1 }, { id: 2 }]) // passes
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
assertBodyContains(values: any | any[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Assert body (array or object) to not contain a subset of the expected value.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```js
|
|
61
|
+
* const body = { id: 1, name: 'post 1' }
|
|
62
|
+
*
|
|
63
|
+
* response.assertBodyNotContains({ id: 1 }) // fails
|
|
64
|
+
* ```
|
|
65
|
+
* @example
|
|
66
|
+
* ```js
|
|
67
|
+
* const body = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
68
|
+
*
|
|
69
|
+
* response.assertBodyNotContains([{ id: 3 }]) // passes
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
assertBodyNotContains(values: any | any[]): void;
|
|
73
|
+
/**
|
|
74
|
+
* Assert body to contain a key.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```js
|
|
78
|
+
* const body = { id: 1, name: 'post 1' }
|
|
79
|
+
*
|
|
80
|
+
* response.assertBodyContainsKey('id') // passes
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
assertBodyContainsKey(key: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* Assert body to not contain a key.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```js
|
|
89
|
+
* const body = { id: 1, name: 'post 1' }
|
|
90
|
+
*
|
|
91
|
+
* response.assertBodyNotContainsKey('id') // fails
|
|
92
|
+
* ```
|
|
93
|
+
* @example
|
|
94
|
+
* ```js
|
|
95
|
+
* const body = { id: 1, name: 'post 1' }
|
|
96
|
+
*
|
|
97
|
+
* response.assertBodyNotContainsKey('createdAt') // passes
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
assertBodyNotContainsKey(key: string): void;
|
|
101
|
+
/**
|
|
102
|
+
* Assert body to contain all keys.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```js
|
|
106
|
+
* const body = { id: 1, name: 'post 1' }
|
|
107
|
+
*
|
|
108
|
+
* response.assertBodyContainsAllKeys(['id', 'post']) // passes
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
assertBodyContainsAllKeys(keys: string[]): void;
|
|
112
|
+
/**
|
|
113
|
+
* Assert body to not contain all keys.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```js
|
|
117
|
+
* const body = { id: 1, name: 'post 1' }
|
|
118
|
+
*
|
|
119
|
+
* response.assertBodyNotContainsAllKeys(['id']) // fails
|
|
120
|
+
* ```
|
|
121
|
+
* @example
|
|
122
|
+
* ```js
|
|
123
|
+
* const body = { id: 1, name: 'post 1' }
|
|
124
|
+
*
|
|
125
|
+
* response.assertBodyNotContainsAllKeys(['createdAt']) // passes
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
assertBodyNotContainsAllKeys(keys: string[]): void;
|
|
129
|
+
/**
|
|
130
|
+
* Assert body (array or object) to be deep equal to the expected value.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```js
|
|
134
|
+
* const body = { id: 1, name: 'post 1' }
|
|
135
|
+
*
|
|
136
|
+
* response.assertBodyDeepEqual({ id: 1 }) // fails
|
|
137
|
+
* ```
|
|
138
|
+
* @example
|
|
139
|
+
* ```js
|
|
140
|
+
* const body = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
141
|
+
*
|
|
142
|
+
* response.assertBodyDeepEqual([{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]) // passes
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
assertBodyDeepEqual(values: any | any[]): void;
|
|
146
|
+
/**
|
|
147
|
+
* Assert body (array or object) to be not deep equal to the expected value.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```js
|
|
151
|
+
* const body = { id: 1, name: 'post 1' }
|
|
152
|
+
*
|
|
153
|
+
* response.assertBodyNotDeepEqual({ id: 1 }) // passes
|
|
154
|
+
* ```
|
|
155
|
+
* @example
|
|
156
|
+
* ```js
|
|
157
|
+
* const body = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
158
|
+
*
|
|
159
|
+
* response.assertBodyNotDeepEqual([{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]) // fails
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
assertBodyNotDeepEqual(values: any | any[]): void;
|
|
163
|
+
/**
|
|
164
|
+
* Assert body to be an array.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```js
|
|
168
|
+
* const body = { id: 1, name: 'post 1' }
|
|
169
|
+
*
|
|
170
|
+
* response.assertBodyIsArray() // fails
|
|
171
|
+
* ```
|
|
172
|
+
* @example
|
|
173
|
+
* ```js
|
|
174
|
+
* const body = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
175
|
+
*
|
|
176
|
+
* response.assertBodyIsArray() // passes
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
assertBodyIsArray(): void;
|
|
180
|
+
/**
|
|
181
|
+
* Assert body to not be an array.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```js
|
|
185
|
+
* const body = { id: 1, name: 'post 1' }
|
|
186
|
+
*
|
|
187
|
+
* response.assertBodyIsNotArray() // passes
|
|
188
|
+
* ```
|
|
189
|
+
* @example
|
|
190
|
+
* ```js
|
|
191
|
+
* const body = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
192
|
+
*
|
|
193
|
+
* response.assertBodyIsNotArray() // fails
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
assertBodyIsNotArray(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Assert body to be an object.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```js
|
|
202
|
+
* const body = { id: 1, name: 'post 1' }
|
|
203
|
+
*
|
|
204
|
+
* response.assertBodyIsObject() // passes
|
|
205
|
+
* ```
|
|
206
|
+
* @example
|
|
207
|
+
* ```js
|
|
208
|
+
* const body = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
209
|
+
*
|
|
210
|
+
* response.assertBodyIsObject() // fails
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
assertBodyIsObject(): void;
|
|
214
|
+
/**
|
|
215
|
+
* Assert body to not be an object.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```js
|
|
219
|
+
* const body = { id: 1, name: 'post 1' }
|
|
220
|
+
*
|
|
221
|
+
* response.assertBodyIsNotObject() // fails
|
|
222
|
+
* ```
|
|
223
|
+
* @example
|
|
224
|
+
* ```js
|
|
225
|
+
* const body = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
226
|
+
*
|
|
227
|
+
* response.assertBodyIsNotObject() // passes
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
assertBodyIsNotObject(): void;
|
|
231
|
+
/**
|
|
232
|
+
* Assert header (array or object) to contain a subset of the expected value.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```js
|
|
236
|
+
* const header = { id: 1, name: 'post 1' }
|
|
237
|
+
*
|
|
238
|
+
* response.assertHeaderContains({ id: 1 }) // passes
|
|
239
|
+
* ```
|
|
240
|
+
* @example
|
|
241
|
+
* ```js
|
|
242
|
+
* const header = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
243
|
+
*
|
|
244
|
+
* response.assertHeaderContains([{ id: 1 }, { id: 2 }]) // passes
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
assertHeaderContains(values: any | any[]): void;
|
|
248
|
+
/**
|
|
249
|
+
* Assert header (array or object) to not contain a subset of the expected value.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```js
|
|
253
|
+
* const header = { id: 1, name: 'post 1' }
|
|
254
|
+
*
|
|
255
|
+
* response.assertHeaderContains({ id: 1 }) // passes
|
|
256
|
+
* ```
|
|
257
|
+
* @example
|
|
258
|
+
* ```js
|
|
259
|
+
* const header = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
260
|
+
*
|
|
261
|
+
* response.assertHeaderContains([{ id: 1 }, { id: 2 }]) // passes
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
assertHeaderNotContains(values: any | any[]): void;
|
|
265
|
+
/**
|
|
266
|
+
* Assert header (array or object) to be deep equal to the expected value.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```js
|
|
270
|
+
* const header = { id: 1, name: 'post 1' }
|
|
271
|
+
*
|
|
272
|
+
* response.assertHeaderDeepEqual({ id: 1 }) // fails
|
|
273
|
+
* ```
|
|
274
|
+
* @example
|
|
275
|
+
* ```js
|
|
276
|
+
* const header = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
277
|
+
*
|
|
278
|
+
* response.assertHeaderDeepEqual([{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]) // passes
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
assertHeaderDeepEqual(values: any | any[]): void;
|
|
282
|
+
/**
|
|
283
|
+
* Assert header (array or object) to be not deep equal to the expected value.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```js
|
|
287
|
+
* const header = { id: 1, name: 'post 1' }
|
|
288
|
+
*
|
|
289
|
+
* response.assertHeaderNotDeepEqual({ id: 1 }) // passes
|
|
290
|
+
* ```
|
|
291
|
+
* @example
|
|
292
|
+
* ```js
|
|
293
|
+
* const header = [{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]
|
|
294
|
+
*
|
|
295
|
+
* response.assertHeaderNotDeepEqual([{ id: 1, name: 'post 1' }, { id: 2, name: 'post 2'}]) // fails
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
assertHeaderNotDeepEqual(values: any | any[]): void;
|
|
299
|
+
/**
|
|
300
|
+
* Assert header to contain a key.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```js
|
|
304
|
+
* const header = { id: 1, name: 'post 1' }
|
|
305
|
+
*
|
|
306
|
+
* response.assertHeaderContainsKey('id') // passes
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
assertHeaderContainsKey(key: string): void;
|
|
310
|
+
/**
|
|
311
|
+
* Assert header to not contain a key.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```js
|
|
315
|
+
* const body = { id: 1, name: 'post 1' }
|
|
316
|
+
*
|
|
317
|
+
* response.assertHeaderNotContainsKey('id') // fails
|
|
318
|
+
* ```
|
|
319
|
+
* @example
|
|
320
|
+
* ```js
|
|
321
|
+
* const body = { id: 1, name: 'post 1' }
|
|
322
|
+
*
|
|
323
|
+
* response.assertHeaderNotContainsKey('createdAt') // passes
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
assertHeaderNotContainsKey(key: string): void;
|
|
327
|
+
/**
|
|
328
|
+
* Assert header to contain all keys.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```js
|
|
332
|
+
* const header = { id: 1, name: 'post 1' }
|
|
333
|
+
*
|
|
334
|
+
* response.assertHeaderContainsAllKeys(['id', 'post']) // passes
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
assertHeaderContainsAllKeys(keys: string[]): void;
|
|
338
|
+
/**
|
|
339
|
+
* Assert header to not contain all keys.
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```js
|
|
343
|
+
* const header = { id: 1, name: 'post 1' }
|
|
344
|
+
*
|
|
345
|
+
* response.assertHeaderNotContainsAllKeys(['id']) // fails
|
|
346
|
+
* ```
|
|
347
|
+
* @example
|
|
348
|
+
* ```js
|
|
349
|
+
* const header = { id: 1, name: 'post 1' }
|
|
350
|
+
*
|
|
351
|
+
* response.assertHeaderNotContainsAllKeys(['createdAt']) // passes
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
assertHeaderNotContainsAllKeys(keys: string[]): void;
|
|
355
|
+
}
|