galbe 0.11.0 → 0.12.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.
@@ -9,6 +9,8 @@ describe('requests', () => {
9
9
  beforeAll(async () => {
10
10
  const galbe = new Galbe()
11
11
 
12
+ galbe.static('/www', './test/resources/static', {})
13
+
12
14
  galbe.get('/test', () => {})
13
15
  galbe.post('/test', () => {})
14
16
  galbe.put('/test', () => {})
@@ -31,8 +33,8 @@ describe('requests', () => {
31
33
  float: $T.number(),
32
34
  integer: $T.integer(),
33
35
  'boolean-true': $T.boolean(),
34
- 'boolean-false': $T.boolean()
35
- }
36
+ 'boolean-false': $T.boolean(),
37
+ },
36
38
  },
37
39
  ctx => {
38
40
  return ctx.headers
@@ -49,8 +51,8 @@ describe('requests', () => {
49
51
  p1: $T.string(),
50
52
  p2: $T.number(),
51
53
  p3: $T.integer(),
52
- p4: $T.boolean()
53
- }
54
+ p4: $T.boolean(),
55
+ },
54
56
  },
55
57
  ctx => {
56
58
  return ctx.params
@@ -69,8 +71,8 @@ describe('requests', () => {
69
71
  p3: $T.boolean(),
70
72
  p4: $T.union([$T.number(), $T.boolean()]),
71
73
  p5: $T.optional($T.string()),
72
- p6: $T.array($T.union([$T.string()]))
73
- }
74
+ p6: $T.array($T.union([$T.string()])),
75
+ },
74
76
  },
75
77
  ctx => {
76
78
  return ctx.query
@@ -78,19 +80,23 @@ describe('requests', () => {
78
80
  )
79
81
 
80
82
  galbe.post('/none', handleBody)
81
- galbe.post('/ba', { body: $T.byteArray() }, handleBody)
82
- galbe.post('/bool', { body: $T.boolean() }, handleBody)
83
- galbe.post('/num', { body: $T.number() }, handleBody)
84
- galbe.post('/str', { body: $T.string() }, handleBody)
85
- galbe.post('/arr', { body: $T.array() }, handleBody)
86
- galbe.post('/obj', { body: $T.object($T.any()) }, handleBody)
87
-
88
- galbe.post('/form', { body: $T.urlForm() }, handleBody)
89
- galbe.post('/mp', { body: $T.multipartForm() }, handleBody)
90
-
91
- galbe.post('/stream/ba', { body: $T.stream($T.byteArray()) }, handleBody)
92
- galbe.post('/stream/str', { body: $T.stream($T.string()) }, handleBody)
93
- galbe.post('/stream/form', { body: $T.stream($T.urlForm()) }, async ctx => {
83
+ galbe.post('/null', { body: $T.null() }, handleBody)
84
+ galbe.post('/ba', { body: { byteArray: $T.byteArray() } }, handleBody)
85
+ galbe.post('/bool', { body: { json: $T.boolean() } }, handleBody)
86
+ galbe.post('/num', { body: { json: $T.number() } }, handleBody)
87
+ galbe.post('/jsonStr', { body: { json: $T.string() } }, handleBody)
88
+ galbe.post('/str', { body: { text: $T.string() } }, handleBody)
89
+ galbe.post('/txtBool', { body: { text: $T.boolean() } }, handleBody)
90
+ galbe.post('/txtNum', { body: { text: $T.number() } }, handleBody)
91
+ galbe.post('/arr', { body: { json: $T.array() } }, handleBody)
92
+ galbe.post('/obj', { body: { json: $T.object($T.any()) } }, handleBody)
93
+
94
+ galbe.post('/form', { body: { urlForm: $T.object() } }, handleBody)
95
+ galbe.post('/mp', { body: { multipart: $T.multipartForm() } }, handleBody)
96
+
97
+ galbe.post('/stream/ba', { body: { byteArray: $T.stream($T.byteArray()) } }, handleBody)
98
+ galbe.post('/stream/str', { body: { text: $T.stream($T.string()) } }, handleBody)
99
+ galbe.post('/stream/form', { body: { urlForm: $T.stream($T.object()) } }, async ctx => {
94
100
  let resp: Record<string, any> = {}
95
101
  for await (const [k, v] of ctx.body) {
96
102
  if (k in resp) {
@@ -99,7 +105,7 @@ describe('requests', () => {
99
105
  }
100
106
  return { type: 'object', content: resp }
101
107
  })
102
- galbe.post('/stream/mp', { body: $T.stream($T.multipartForm()) }, async ctx => {
108
+ galbe.post('/stream/mp', { body: { multipart: $T.stream($T.multipartForm()) } }, async ctx => {
103
109
  let resp: Record<string, any> = {}
104
110
  for await (const field of ctx.body) {
105
111
  let k = field?.headers.name
@@ -118,17 +124,21 @@ describe('requests', () => {
118
124
  bool: $T.boolean(),
119
125
  arrayStr: $T.array($T.string()),
120
126
  arrayNumber: $T.array($T.number()),
121
- arrayBool: $T.array($T.boolean())
127
+ arrayBool: $T.array($T.boolean()),
122
128
  }
123
129
 
124
130
  galbe.post(
125
131
  '/mp/file',
126
- { body: $T.multipartForm({ imgFile: $T.byteArray(), jsonFile: $T.object(schema_jsonFile) }) },
132
+ { body: { multipart: $T.multipartForm({ imgFile: $T.byteArray(), jsonFile: $T.object(schema_jsonFile) }) } },
127
133
  handleBody
128
134
  )
129
135
  galbe.post(
130
136
  '/mp/stream/file',
131
- { body: $T.stream($T.multipartForm({ imgFile: $T.byteArray(), jsonFile: $T.object(schema_jsonFile) })) },
137
+ {
138
+ body: {
139
+ multipart: $T.stream($T.multipartForm({ imgFile: $T.byteArray(), jsonFile: $T.object(schema_jsonFile) })),
140
+ },
141
+ },
132
142
  async ctx => {
133
143
  if (isAsyncIterator(ctx.body)) {
134
144
  const chunks: any[] = []
@@ -143,14 +153,14 @@ describe('requests', () => {
143
153
  }
144
154
  }
145
155
  )
146
- galbe.post('/ba/file', { body: $T.byteArray() }, async ctx => {
156
+ galbe.post('/ba/file', { body: { byteArray: $T.byteArray() } }, async ctx => {
147
157
  if (ctx?.body instanceof Uint8Array) {
148
158
  return { type: 'byteArray', content: await fileHash(ctx.body) }
149
159
  } else {
150
160
  return { type: null, content: 'error' }
151
161
  }
152
162
  })
153
- galbe.post('/ba/stream/file', { body: $T.stream($T.byteArray()) }, async ctx => {
163
+ galbe.post('/ba/stream/file', { body: { byteArray: $T.stream($T.byteArray()) } }, async ctx => {
154
164
  if (isAsyncIterator(ctx.body)) {
155
165
  let bytes = new Uint8Array()
156
166
  for await (const b of ctx.body) {
@@ -165,6 +175,48 @@ describe('requests', () => {
165
175
  await galbe.listen(port)
166
176
  })
167
177
 
178
+ test('static directory', async () => {
179
+ const testCases = [
180
+ {
181
+ path: `http://localhost:${port}/www`,
182
+ file: 'test/resources/static/index.html',
183
+ type: 'text/html;charset=utf-8',
184
+ },
185
+ {
186
+ path: `http://localhost:${port}/www/index.html`,
187
+ file: 'test/resources/static/index.html',
188
+ type: 'text/html;charset=utf-8',
189
+ },
190
+ {
191
+ path: `http://localhost:${port}/www/sub`,
192
+ file: 'test/resources/static/sub/index.html',
193
+ type: 'text/html;charset=utf-8',
194
+ },
195
+ {
196
+ path: `http://localhost:${port}/www/sub/index.html`,
197
+ file: 'test/resources/static/sub/index.html',
198
+ type: 'text/html;charset=utf-8',
199
+ },
200
+ {
201
+ path: `http://localhost:${port}/www/sub/other`,
202
+ file: 'test/resources/static/sub/other.html',
203
+ type: 'text/html;charset=utf-8',
204
+ },
205
+ {
206
+ path: `http://localhost:${port}/www/chameleon.png`,
207
+ file: 'test/resources/static/chameleon.png',
208
+ type: 'image/png',
209
+ },
210
+ ]
211
+ for (const tc of testCases) {
212
+ let resp = await fetch(tc.path)
213
+ expect(resp.ok).toBeTrue()
214
+ const expected = await Bun.file(tc.file).text()
215
+ expect(await resp.text()).toBe(expected)
216
+ expect(resp.headers.get('content-type')).toBe(tc.type)
217
+ }
218
+ })
219
+
168
220
  test('methods, empty calls', async () => {
169
221
  for (let method of METHODS) {
170
222
  let resp = await fetch(`http://localhost:${port}/test`, { method: method.toUpperCase() })
@@ -183,7 +235,7 @@ describe('requests', () => {
183
235
  const headers = {
184
236
  String: 'hello mom',
185
237
  Number: '42',
186
- Boolean: 'true'
238
+ Boolean: 'true',
187
239
  }
188
240
  const expected = Object.fromEntries(Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v]))
189
241
 
@@ -197,7 +249,7 @@ describe('requests', () => {
197
249
  const expected = {
198
250
  param1: 'one',
199
251
  param2: '2',
200
- param3: 'true'
252
+ param3: 'true',
201
253
  }
202
254
  let resp = await fetch(`http://localhost:${port}/params/one/separate/2/true`)
203
255
  let body = await resp.json()
@@ -209,7 +261,7 @@ describe('requests', () => {
209
261
  const expected = {
210
262
  param1: 'one',
211
263
  param2: '2',
212
- param3: 'true'
264
+ param3: 'true',
213
265
  }
214
266
  let resp = await fetch(`http://localhost:${port}/query/params?param1=one&param2=2&param3=true`)
215
267
  let body = await resp.json()
@@ -220,7 +272,8 @@ describe('requests', () => {
220
272
  test('no body, no header', async () => {
221
273
  const cases: Case[] = [
222
274
  { body: null, type: undefined, schema: 'none', expected: { status: 200, resp: null } },
223
- { body: null, type: undefined, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: '' } },
275
+ { body: null, type: undefined, schema: 'null', expected: { status: 200, resp: null } },
276
+ { body: null, type: undefined, schema: 'ba', expected: { status: 400 } },
224
277
  { body: null, type: undefined, schema: 'bool', expected: { status: 400 } },
225
278
  { body: null, type: undefined, schema: 'num', expected: { status: 400 } },
226
279
  { body: null, type: undefined, schema: 'str', expected: { status: 400 } },
@@ -228,18 +281,18 @@ describe('requests', () => {
228
281
  { body: null, type: undefined, schema: 'obj', expected: { status: 400 } },
229
282
  { body: null, type: undefined, schema: 'form', expected: { status: 400 } },
230
283
  { body: null, type: undefined, schema: 'mp', expected: { status: 400 } },
231
- { body: null, type: undefined, schema: 'stream/ba', expected: { status: 200, type: 'ReadableStream', resp: '' } },
284
+ { body: null, type: undefined, schema: 'stream/ba', expected: { status: 400 } },
232
285
  { body: null, type: undefined, schema: 'stream/str', expected: { status: 400 } },
233
286
  { body: null, type: undefined, schema: 'stream/form', expected: { status: 400 } },
234
- { body: null, type: undefined, schema: 'stream/mp', expected: { status: 400 } }
287
+ { body: null, type: undefined, schema: 'stream/mp', expected: { status: 400 } },
235
288
  ]
236
289
  for (let { body, type, schema, expected } of cases) {
237
290
  let resp = await fetch(`http://localhost:${port}/${schema}`, {
238
291
  method: 'POST',
239
292
  body,
240
293
  headers: {
241
- ...(type ? { 'content-type': type } : {})
242
- }
294
+ ...(type ? { 'content-type': type } : {}),
295
+ },
243
296
  })
244
297
 
245
298
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -254,7 +307,7 @@ describe('requests', () => {
254
307
  test('no body, application/octet-stream', async () => {
255
308
  const contentType = 'application/octet-stream'
256
309
  const cases: Case[] = [
257
- { body: null, type: contentType, schema: 'none', expected: { status: 200, resp: '' } },
310
+ { body: null, type: contentType, schema: 'none', expected: { status: 200, type: 'byteArray', resp: '' } },
258
311
  { body: null, type: contentType, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: '' } },
259
312
  { body: null, type: contentType, schema: 'bool', expected: { status: 400 } },
260
313
  { body: null, type: contentType, schema: 'num', expected: { status: 400 } },
@@ -267,11 +320,11 @@ describe('requests', () => {
267
320
  body: null,
268
321
  type: contentType,
269
322
  schema: 'stream/ba',
270
- expected: { status: 200, type: 'ReadableStream', resp: '' }
323
+ expected: { status: 200, type: 'ReadableStream', resp: '' },
271
324
  },
272
325
  { body: null, type: contentType, schema: 'stream/str', expected: { status: 400 } },
273
326
  { body: null, type: contentType, schema: 'stream/form', expected: { status: 400 } },
274
- { body: null, type: contentType, schema: 'stream/mp', expected: { status: 400 } }
327
+ { body: null, type: contentType, schema: 'stream/mp', expected: { status: 400 } },
275
328
  ]
276
329
 
277
330
  for (let { body, type, schema, expected } of cases) {
@@ -279,8 +332,8 @@ describe('requests', () => {
279
332
  method: 'POST',
280
333
  body,
281
334
  headers: {
282
- ...(type ? { 'content-type': type } : {})
283
- }
335
+ ...(type ? { 'content-type': type } : {}),
336
+ },
284
337
  })
285
338
 
286
339
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -295,24 +348,19 @@ describe('requests', () => {
295
348
  test('no body, application/json', async () => {
296
349
  const contentType = 'application/json'
297
350
  const cases: Case[] = [
298
- { body: null, type: contentType, schema: 'none', expected: { status: 400 } },
299
- { body: null, type: contentType, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: '' } },
351
+ { body: null, type: contentType, schema: 'none', expected: { status: 200, resp: null } },
352
+ { body: null, type: contentType, schema: 'ba', expected: { status: 400 } },
300
353
  { body: null, type: contentType, schema: 'bool', expected: { status: 400 } },
301
354
  { body: null, type: contentType, schema: 'num', expected: { status: 400 } },
302
355
  { body: null, type: contentType, schema: 'str', expected: { status: 400 } },
303
356
  { body: null, type: contentType, schema: 'arr', expected: { status: 400 } },
304
- { body: null, type: contentType, schema: 'obj', expected: { status: 400 } },
357
+ { body: null, type: contentType, schema: 'obj', expected: { status: 200, resp: null } },
305
358
  { body: null, type: contentType, schema: 'form', expected: { status: 400 } },
306
359
  { body: null, type: contentType, schema: 'mp', expected: { status: 400 } },
307
- {
308
- body: null,
309
- type: contentType,
310
- schema: 'stream/ba',
311
- expected: { status: 200, type: 'ReadableStream', resp: '' }
312
- },
360
+ { body: null, type: contentType, schema: 'stream/ba', expected: { status: 400 } },
313
361
  { body: null, type: contentType, schema: 'stream/str', expected: { status: 400 } },
314
362
  { body: null, type: contentType, schema: 'stream/form', expected: { status: 400 } },
315
- { body: null, type: contentType, schema: 'stream/mp', expected: { status: 400 } }
363
+ { body: null, type: contentType, schema: 'stream/mp', expected: { status: 400 } },
316
364
  ]
317
365
 
318
366
  for (let { body, type, schema, expected } of cases) {
@@ -320,8 +368,8 @@ describe('requests', () => {
320
368
  method: 'POST',
321
369
  body,
322
370
  headers: {
323
- ...(type ? { 'content-type': type } : {})
324
- }
371
+ ...(type ? { 'content-type': type } : {}),
372
+ },
325
373
  })
326
374
 
327
375
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -336,24 +384,24 @@ describe('requests', () => {
336
384
  test('no body, text/plain', async () => {
337
385
  const contentType = 'text/plain'
338
386
  const cases: Case[] = [
339
- { body: null, type: contentType, schema: 'none', expected: { status: 400 } },
340
- { body: null, type: contentType, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: '' } },
387
+ { body: null, type: contentType, schema: 'none', expected: { status: 200, resp: '' } },
388
+ { body: null, type: contentType, schema: 'ba', expected: { status: 400 } },
341
389
  { body: null, type: contentType, schema: 'bool', expected: { status: 400 } },
342
390
  { body: null, type: contentType, schema: 'num', expected: { status: 400 } },
343
- { body: null, type: contentType, schema: 'str', expected: { status: 400 } },
391
+ { body: null, type: contentType, schema: 'str', expected: { status: 200, resp: '' } },
344
392
  { body: null, type: contentType, schema: 'arr', expected: { status: 400 } },
345
393
  { body: null, type: contentType, schema: 'obj', expected: { status: 400 } },
346
394
  { body: null, type: contentType, schema: 'form', expected: { status: 400 } },
347
395
  { body: null, type: contentType, schema: 'mp', expected: { status: 400 } },
396
+ { body: null, type: contentType, schema: 'stream/ba', expected: { status: 400 } },
348
397
  {
349
398
  body: null,
350
399
  type: contentType,
351
- schema: 'stream/ba',
352
- expected: { status: 200, type: 'ReadableStream', resp: '' }
400
+ schema: 'stream/str',
401
+ expected: { status: 200, type: 'ReadableStream', resp: '' },
353
402
  },
354
- { body: null, type: contentType, schema: 'stream/str', expected: { status: 400 } },
355
403
  { body: null, type: contentType, schema: 'stream/form', expected: { status: 400 } },
356
- { body: null, type: contentType, schema: 'stream/mp', expected: { status: 400 } }
404
+ { body: null, type: contentType, schema: 'stream/mp', expected: { status: 400 } },
357
405
  ]
358
406
 
359
407
  for (let { body, type, schema, expected } of cases) {
@@ -361,8 +409,8 @@ describe('requests', () => {
361
409
  method: 'POST',
362
410
  body,
363
411
  headers: {
364
- ...(type ? { 'content-type': type } : {})
365
- }
412
+ ...(type ? { 'content-type': type } : {}),
413
+ },
366
414
  })
367
415
 
368
416
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -377,24 +425,19 @@ describe('requests', () => {
377
425
  test('no body, application/x-www-form-urlencoded', async () => {
378
426
  const contentType = 'application/x-www-form-urlencoded'
379
427
  const cases: Case[] = [
380
- { body: null, type: contentType, schema: 'none', expected: { status: 400 } },
381
- { body: null, type: contentType, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: '' } },
428
+ { body: null, type: contentType, schema: 'none', expected: { status: 200, resp: {} } },
429
+ { body: null, type: contentType, schema: 'ba', expected: { status: 400 } },
382
430
  { body: null, type: contentType, schema: 'bool', expected: { status: 400 } },
383
431
  { body: null, type: contentType, schema: 'num', expected: { status: 400 } },
384
432
  { body: null, type: contentType, schema: 'str', expected: { status: 400 } },
385
433
  { body: null, type: contentType, schema: 'arr', expected: { status: 400 } },
386
434
  { body: null, type: contentType, schema: 'obj', expected: { status: 400 } },
387
- { body: null, type: contentType, schema: 'form', expected: { status: 400 } },
435
+ { body: null, type: contentType, schema: 'form', expected: { status: 200, resp: {} } },
388
436
  { body: null, type: contentType, schema: 'mp', expected: { status: 400 } },
389
- {
390
- body: null,
391
- type: contentType,
392
- schema: 'stream/ba',
393
- expected: { status: 200, type: 'ReadableStream', resp: '' }
394
- },
437
+ { body: null, type: contentType, schema: 'stream/ba', expected: { status: 400 } },
395
438
  { body: null, type: contentType, schema: 'stream/str', expected: { status: 400 } },
396
- { body: null, type: contentType, schema: 'stream/form', expected: { status: 400 } },
397
- { body: null, type: contentType, schema: 'stream/mp', expected: { status: 400 } }
439
+ { body: null, type: contentType, schema: 'stream/form', expected: { status: 200, resp: {} } },
440
+ { body: null, type: contentType, schema: 'stream/mp', expected: { status: 400 } },
398
441
  ]
399
442
 
400
443
  for (let { body, type, schema, expected } of cases) {
@@ -402,8 +445,8 @@ describe('requests', () => {
402
445
  method: 'POST',
403
446
  body,
404
447
  headers: {
405
- ...(type ? { 'content-type': type } : {})
406
- }
448
+ ...(type ? { 'content-type': type } : {}),
449
+ },
407
450
  })
408
451
 
409
452
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -418,24 +461,24 @@ describe('requests', () => {
418
461
  test('no body, multipart/form-data', async () => {
419
462
  const contentType = 'multipart/form-data'
420
463
  const cases: Case[] = [
421
- { body: null, type: contentType, schema: 'none', expected: { status: 400 } },
422
- { body: null, type: contentType, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: '' } },
464
+ { body: null, type: contentType, schema: 'none', expected: { status: 200, resp: {} } },
465
+ { body: null, type: contentType, schema: 'ba', expected: { status: 400 } },
423
466
  { body: null, type: contentType, schema: 'bool', expected: { status: 400 } },
424
467
  { body: null, type: contentType, schema: 'num', expected: { status: 400 } },
425
468
  { body: null, type: contentType, schema: 'str', expected: { status: 400 } },
426
469
  { body: null, type: contentType, schema: 'arr', expected: { status: 400 } },
427
470
  { body: null, type: contentType, schema: 'obj', expected: { status: 400 } },
428
471
  { body: null, type: contentType, schema: 'form', expected: { status: 400 } },
429
- { body: null, type: contentType, schema: 'mp', expected: { status: 400 } },
472
+ { body: null, type: contentType, schema: 'mp', expected: { status: 200, resp: {} } },
473
+ { body: null, type: contentType, schema: 'stream/ba', expected: { status: 400 } },
474
+ { body: null, type: contentType, schema: 'stream/str', expected: { status: 400 } },
475
+ { body: null, type: contentType, schema: 'stream/form', expected: { status: 400 } },
430
476
  {
431
477
  body: null,
432
478
  type: contentType,
433
- schema: 'stream/ba',
434
- expected: { status: 200, type: 'ReadableStream', resp: '' }
479
+ schema: 'stream/mp',
480
+ expected: { status: 200, resp: { undefined: { headers: {} } } },
435
481
  },
436
- { body: null, type: contentType, schema: 'stream/str', expected: { status: 400 } },
437
- { body: null, type: contentType, schema: 'stream/form', expected: { status: 400 } },
438
- { body: null, type: contentType, schema: 'stream/mp', expected: { status: 400 } }
439
482
  ]
440
483
 
441
484
  for (let { body, type, schema, expected } of cases) {
@@ -443,8 +486,8 @@ describe('requests', () => {
443
486
  method: 'POST',
444
487
  body,
445
488
  headers: {
446
- ...(type ? { 'content-type': type } : {})
447
- }
489
+ ...(type ? { 'content-type': type } : {}),
490
+ },
448
491
  })
449
492
 
450
493
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -458,39 +501,44 @@ describe('requests', () => {
458
501
 
459
502
  test('body, no header', async () => {
460
503
  const cases: Case[] = [
461
- { body: 'test', schema: 'none', expected: { status: 200, type: 'byteArray', resp: 'test' } },
462
- { body: 'test', schema: 'ba', expected: { status: 200, type: 'byteArray', resp: 'test' } },
463
- { body: 'true', schema: 'bool', expected: { status: 200, type: 'boolean', resp: true } },
464
- { body: 'false', schema: 'bool', expected: { status: 200, type: 'boolean', resp: false } },
504
+ {
505
+ body: 'test',
506
+ schema: 'none',
507
+ expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries([116, 101, 115, 116].entries()) },
508
+ },
509
+ { body: 'test', schema: 'null', expected: { status: 400 } },
510
+ { body: 'test', schema: 'ba', expected: { status: 400 } },
511
+ { body: 'true', schema: 'bool', expected: { status: 400 } },
512
+ { body: 'false', schema: 'bool', expected: { status: 400 } },
465
513
  { body: 'test', schema: 'bool', expected: { status: 400 } },
466
- { body: '0', schema: 'num', expected: { status: 200, type: 'number', resp: 0 } },
467
- { body: '42', schema: 'num', expected: { status: 200, type: 'number', resp: 42 } },
468
- { body: '-8000', schema: 'num', expected: { status: 200, type: 'number', resp: -8000 } },
469
- { body: '3.14', schema: 'num', expected: { status: 200, type: 'number', resp: 3.14 } },
514
+ { body: '0', schema: 'num', expected: { status: 400 } },
515
+ { body: '42', schema: 'num', expected: { status: 400 } },
516
+ { body: '-8000', schema: 'num', expected: { status: 400 } },
517
+ { body: '3.14', schema: 'num', expected: { status: 400 } },
470
518
  { body: 'test', schema: 'num', expected: { status: 400 } },
471
- { body: 'test', schema: 'str', expected: { status: 200, type: 'string', resp: 'test' } },
472
- { body: '42', schema: 'str', expected: { status: 200, type: 'string', resp: '42' } },
473
- { body: 'false', schema: 'str', expected: { status: 200, type: 'string', resp: 'false' } },
474
- { body: '[]', schema: 'arr', expected: { status: 200, type: 'array', resp: [] } },
519
+ { body: 'test', schema: 'str', expected: { status: 400 } },
520
+ { body: '42', schema: 'str', expected: { status: 400 } },
521
+ { body: 'false', schema: 'str', expected: { status: 400 } },
522
+ { body: '[]', schema: 'arr', expected: { status: 400 } },
475
523
  {
476
524
  body: '["a", 42, true, null, {"foo": "bar"}]',
477
525
  schema: 'arr',
478
- expected: { status: 200, type: 'array', resp: ['a', 42, true, null, { foo: 'bar' }] }
526
+ expected: { status: 400 },
479
527
  },
480
528
  { body: 'test', schema: 'arr', expected: { status: 400 } },
481
- { body: '{}', schema: 'obj', expected: { status: 200, type: 'object', resp: {} } },
482
- { body: '{"foo": "bar"}', schema: 'obj', expected: { status: 200, type: 'object', resp: { foo: 'bar' } } },
529
+ { body: '{}', schema: 'obj', expected: { status: 400 } },
530
+ { body: '{"foo": "bar"}', schema: 'obj', expected: { status: 400 } },
483
531
  { body: 'test', schema: 'obj', expected: { status: 400 } },
484
532
  { body: 'test', schema: 'form', expected: { status: 400 } },
485
533
  { body: 'test', schema: 'mp', expected: { status: 400 } },
486
534
  {
487
535
  body: 'test',
488
536
  schema: 'stream/ba',
489
- expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries([116, 101, 115, 116].entries()) }
537
+ expected: { status: 400 },
490
538
  },
491
- { body: 'test', schema: 'stream/str', expected: { status: 200, type: 'AsyncIterator', resp: 'test' } },
539
+ { body: 'test', schema: 'stream/str', expected: { status: 400 } },
492
540
  { body: 'test', schema: 'stream/form', expected: { status: 400 } },
493
- { body: 'test', schema: 'stream/mp', expected: { status: 400 } }
541
+ { body: 'test', schema: 'stream/mp', expected: { status: 400 } },
494
542
  ]
495
543
 
496
544
  for (let { body, type, schema, expected } of cases) {
@@ -498,14 +546,12 @@ describe('requests', () => {
498
546
  method: 'POST',
499
547
  body,
500
548
  headers: {
501
- ...(type ? { 'content-type': type } : {})
502
- }
549
+ ...(type ? { 'content-type': type } : {}),
550
+ },
503
551
  })
504
552
 
505
553
  let respBody = (await resp.json()) as { type: string; content: any }
506
554
 
507
- console.log(respBody)
508
-
509
555
  expect(resp.status).toBe(expected.status)
510
556
  if (expected.type) expect(respBody.type).toEqual(expected.type)
511
557
  if (respBody.type === 'object' && expected.resp === null) expect(respBody.content).toBeNull
@@ -519,31 +565,31 @@ describe('requests', () => {
519
565
  const cases: Case[] = [
520
566
  { body: 'test', type: contentType, schema: 'none', expected: { status: 200, type: 'byteArray', resp: 'test' } },
521
567
  { body: 'test', type: contentType, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: 'test' } },
522
- { body: 'true', type: contentType, schema: 'bool', expected: { status: 200, type: 'boolean', resp: true } },
523
- { body: 'false', type: contentType, schema: 'bool', expected: { status: 200, type: 'boolean', resp: false } },
568
+ { body: 'true', type: contentType, schema: 'bool', expected: { status: 400 } },
569
+ { body: 'false', type: contentType, schema: 'bool', expected: { status: 400 } },
524
570
  { body: 'test', type: contentType, schema: 'bool', expected: { status: 400 } },
525
- { body: '0', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: 0 } },
526
- { body: '42', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: 42 } },
527
- { body: '-8000', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: -8000 } },
528
- { body: '3.14', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: 3.14 } },
571
+ { body: '0', type: contentType, schema: 'num', expected: { status: 400 } },
572
+ { body: '42', type: contentType, schema: 'num', expected: { status: 400 } },
573
+ { body: '-8000', type: contentType, schema: 'num', expected: { status: 400 } },
574
+ { body: '3.14', type: contentType, schema: 'num', expected: { status: 400 } },
529
575
  { body: 'test', type: contentType, schema: 'num', expected: { status: 400 } },
530
- { body: 'test', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: 'test' } },
531
- { body: '42', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: '42' } },
532
- { body: 'false', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: 'false' } },
533
- { body: '[]', type: contentType, schema: 'arr', expected: { status: 200, type: 'array', resp: [] } },
576
+ { body: 'test', type: contentType, schema: 'str', expected: { status: 400 } },
577
+ { body: '42', type: contentType, schema: 'str', expected: { status: 400 } },
578
+ { body: 'false', type: contentType, schema: 'str', expected: { status: 400 } },
579
+ { body: '[]', type: contentType, schema: 'arr', expected: { status: 400 } },
534
580
  {
535
581
  body: '["a", 42, true, null, {"foo": "bar"}]',
536
582
  type: contentType,
537
583
  schema: 'arr',
538
- expected: { status: 200, type: 'array', resp: ['a', 42, true, null, { foo: 'bar' }] }
584
+ expected: { status: 400 },
539
585
  },
540
586
  { body: 'test', type: contentType, schema: 'arr', expected: { status: 400 } },
541
- { body: '{}', type: contentType, schema: 'obj', expected: { status: 200, type: 'object', resp: {} } },
587
+ { body: '{}', type: contentType, schema: 'obj', expected: { status: 400 } },
542
588
  {
543
589
  body: '{"foo": "bar"}',
544
590
  type: contentType,
545
591
  schema: 'obj',
546
- expected: { status: 200, type: 'object', resp: { foo: 'bar' } }
592
+ expected: { status: 400 },
547
593
  },
548
594
  { body: 'test', type: contentType, schema: 'obj', expected: { status: 400 } },
549
595
  { body: 'test', type: contentType, schema: 'form', expected: { status: 400 } },
@@ -552,16 +598,20 @@ describe('requests', () => {
552
598
  body: 'test',
553
599
  type: contentType,
554
600
  schema: 'stream/ba',
555
- expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries(new Uint8Array([116, 101, 115, 116]).entries()) }
601
+ expected: {
602
+ status: 200,
603
+ type: 'AsyncIterator',
604
+ resp: Object.fromEntries(new Uint8Array([116, 101, 115, 116]).entries()),
605
+ },
556
606
  },
557
607
  {
558
608
  body: 'test',
559
609
  type: contentType,
560
610
  schema: 'stream/str',
561
- expected: { status: 200, type: 'AsyncIterator', resp: 'test' }
611
+ expected: { status: 400 },
562
612
  },
563
613
  { body: 'test', type: contentType, schema: 'stream/form', expected: { status: 400 } },
564
- { body: 'test', type: contentType, schema: 'stream/mp', expected: { status: 400 } }
614
+ { body: 'test', type: contentType, schema: 'stream/mp', expected: { status: 400 } },
565
615
  ]
566
616
 
567
617
  for (let { body, type, schema, expected } of cases) {
@@ -569,8 +619,8 @@ describe('requests', () => {
569
619
  method: 'POST',
570
620
  body,
571
621
  headers: {
572
- ...(type ? { 'content-type': type } : {})
573
- }
622
+ ...(type ? { 'content-type': type } : {}),
623
+ },
574
624
  })
575
625
 
576
626
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -589,10 +639,10 @@ describe('requests', () => {
589
639
  body: '{"foo":"bar"}',
590
640
  type: contentType,
591
641
  schema: 'none',
592
- expected: { status: 200, type: 'object', resp: { foo: 'bar' } }
642
+ expected: { status: 200, type: 'object', resp: { foo: 'bar' } },
593
643
  },
594
644
  { body: 'test', type: contentType, schema: 'none', expected: { status: 400 } },
595
- { body: 'test', type: contentType, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: 'test' } },
645
+ { body: 'test', type: contentType, schema: 'ba', expected: { status: 400 } },
596
646
  { body: 'true', type: contentType, schema: 'bool', expected: { status: 200, type: 'boolean', resp: true } },
597
647
  { body: 'false', type: contentType, schema: 'bool', expected: { status: 200, type: 'boolean', resp: false } },
598
648
  { body: 'test', type: contentType, schema: 'bool', expected: { status: 400 } },
@@ -602,16 +652,25 @@ describe('requests', () => {
602
652
  { body: '-8000', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: -8000 } },
603
653
  { body: '3.14', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: 3.14 } },
604
654
  { body: 'test', type: contentType, schema: 'num', expected: { status: 400 } },
605
- { body: '"test"', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: 'test' } },
606
- { body: '"42"', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: '42' } },
607
- { body: '"false"', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: 'false' } },
655
+ { body: '"test"', type: contentType, schema: 'str', expected: { status: 400 } },
656
+ { body: '"42"', type: contentType, schema: 'str', expected: { status: 400 } },
657
+ { body: '"false"', type: contentType, schema: 'str', expected: { status: 400 } },
608
658
  { body: 'test', type: contentType, schema: 'str', expected: { status: 400 } },
659
+ { body: '"test"', type: contentType, schema: 'jsonStr', expected: { status: 200, type: 'string', resp: 'test' } },
660
+ { body: '"42"', type: contentType, schema: 'jsonStr', expected: { status: 200, type: 'string', resp: '42' } },
661
+ {
662
+ body: '"false"',
663
+ type: contentType,
664
+ schema: 'jsonStr',
665
+ expected: { status: 200, type: 'string', resp: 'false' },
666
+ },
667
+ { body: 'test', type: contentType, schema: 'jsonStr', expected: { status: 400 } },
609
668
  { body: '[]', type: contentType, schema: 'arr', expected: { status: 200, type: 'array', resp: [] } },
610
669
  {
611
670
  body: '["a", 42, true, null, {"foo": "bar"}]',
612
671
  type: contentType,
613
672
  schema: 'arr',
614
- expected: { status: 200, type: 'array', resp: ['a', 42, true, null, { foo: 'bar' }] }
673
+ expected: { status: 200, type: 'array', resp: ['a', 42, true, null, { foo: 'bar' }] },
615
674
  },
616
675
  { body: 'test', type: contentType, schema: 'arr', expected: { status: 400 } },
617
676
  { body: '{}', type: contentType, schema: 'obj', expected: { status: 200, type: 'object', resp: {} } },
@@ -619,7 +678,7 @@ describe('requests', () => {
619
678
  body: '{"foo": "bar"}',
620
679
  type: contentType,
621
680
  schema: 'obj',
622
- expected: { status: 200, type: 'object', resp: { foo: 'bar' } }
681
+ expected: { status: 200, type: 'object', resp: { foo: 'bar' } },
623
682
  },
624
683
  { body: 'test', type: contentType, schema: 'obj', expected: { status: 400 } },
625
684
  { body: 'test', type: contentType, schema: 'form', expected: { status: 400 } },
@@ -628,16 +687,16 @@ describe('requests', () => {
628
687
  body: 'test',
629
688
  type: contentType,
630
689
  schema: 'stream/ba',
631
- expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries(new Uint8Array([116, 101, 115, 116]).entries()) }
690
+ expected: { status: 400 },
632
691
  },
633
692
  {
634
693
  body: 'test',
635
694
  type: contentType,
636
695
  schema: 'stream/str',
637
- expected: { status: 200, type: 'AsyncIterator', resp: 'test' }
696
+ expected: { status: 400 },
638
697
  },
639
698
  { body: 'test', type: contentType, schema: 'stream/form', expected: { status: 400 } },
640
- { body: 'test', type: contentType, schema: 'stream/mp', expected: { status: 400 } }
699
+ { body: 'test', type: contentType, schema: 'stream/mp', expected: { status: 400 } },
641
700
  ]
642
701
 
643
702
  for (let { body, type, schema, expected } of cases) {
@@ -645,8 +704,8 @@ describe('requests', () => {
645
704
  method: 'POST',
646
705
  body,
647
706
  headers: {
648
- ...(type ? { 'content-type': type } : {})
649
- }
707
+ ...(type ? { 'content-type': type } : {}),
708
+ },
650
709
  })
651
710
 
652
711
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -662,34 +721,43 @@ describe('requests', () => {
662
721
  const contentType = 'text/plain'
663
722
  const cases: Case[] = [
664
723
  { body: 'test', type: contentType, schema: 'none', expected: { status: 200, type: 'string', resp: 'test' } },
665
- { body: 'test', type: contentType, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: 'test' } },
666
- { body: 'true', type: contentType, schema: 'bool', expected: { status: 200, type: 'boolean', resp: true } },
667
- { body: 'false', type: contentType, schema: 'bool', expected: { status: 200, type: 'boolean', resp: false } },
724
+ { body: 'test', type: contentType, schema: 'ba', expected: { status: 400 } },
725
+ { body: 'true', type: contentType, schema: 'bool', expected: { status: 400 } },
726
+ { body: 'false', type: contentType, schema: 'bool', expected: { status: 400 } },
668
727
  { body: 'test', type: contentType, schema: 'bool', expected: { status: 400 } },
669
728
  { body: '0', type: contentType, schema: 'bool', expected: { status: 400 } },
670
- { body: '0', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: 0 } },
671
- { body: '42', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: 42 } },
672
- { body: '-8000', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: -8000 } },
673
- { body: '3.14', type: contentType, schema: 'num', expected: { status: 200, type: 'number', resp: 3.14 } },
674
- { body: 'test', type: contentType, schema: 'num', expected: { status: 400 } },
729
+ { body: 'true', type: contentType, schema: 'txtBool', expected: { status: 200, type: 'boolean', resp: true } },
730
+ { body: 'false', type: contentType, schema: 'txtBool', expected: { status: 200, type: 'boolean', resp: false } },
731
+ { body: 'test', type: contentType, schema: 'txtBool', expected: { status: 400 } },
732
+ { body: '0', type: contentType, schema: 'txtBool', expected: { status: 400 } },
733
+ { body: '0', type: contentType, schema: 'num', expected: { status: 400 } },
734
+ { body: '42', type: contentType, schema: 'num', expected: { status: 400 } },
735
+ { body: '-8000', type: contentType, schema: 'num', expected: { status: 400 } },
736
+ { body: '3.14', type: contentType, schema: 'num', expected: { status: 400 } },
737
+ { body: 'test', type: contentType, schema: 'num', expected: { status: 400 } }, //
738
+ { body: '0', type: contentType, schema: 'txtNum', expected: { status: 200, type: 'number', resp: 0 } },
739
+ { body: '42', type: contentType, schema: 'txtNum', expected: { status: 200, type: 'number', resp: 42 } },
740
+ { body: '-8000', type: contentType, schema: 'txtNum', expected: { status: 200, type: 'number', resp: -8000 } },
741
+ { body: '3.14', type: contentType, schema: 'txtNum', expected: { status: 200, type: 'number', resp: 3.14 } },
742
+ { body: 'test', type: contentType, schema: 'txtNum', expected: { status: 400 } },
675
743
  { body: 'test', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: 'test' } },
676
744
  { body: '"test"', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: '"test"' } },
677
745
  { body: '42', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: '42' } },
678
746
  { body: 'false', type: contentType, schema: 'str', expected: { status: 200, type: 'string', resp: 'false' } },
679
- { body: '[]', type: contentType, schema: 'arr', expected: { status: 200, type: 'array', resp: [] } },
747
+ { body: '[]', type: contentType, schema: 'arr', expected: { status: 400 } },
680
748
  {
681
749
  body: '["a", 42, true, null, {"foo": "bar"}]',
682
750
  type: contentType,
683
751
  schema: 'arr',
684
- expected: { status: 200, type: 'array', resp: ['a', 42, true, null, { foo: 'bar' }] }
752
+ expected: { status: 400 },
685
753
  },
686
754
  { body: 'test', type: contentType, schema: 'arr', expected: { status: 400 } },
687
- { body: '{}', type: contentType, schema: 'obj', expected: { status: 200, type: 'object', resp: {} } },
755
+ { body: '{}', type: contentType, schema: 'obj', expected: { status: 400 } },
688
756
  {
689
757
  body: '{"foo": "bar"}',
690
758
  type: contentType,
691
759
  schema: 'obj',
692
- expected: { status: 200, type: 'object', resp: { foo: 'bar' } }
760
+ expected: { status: 400 },
693
761
  },
694
762
  { body: 'test', type: contentType, schema: 'obj', expected: { status: 400 } },
695
763
  { body: 'test', type: contentType, schema: 'form', expected: { status: 400 } },
@@ -698,16 +766,18 @@ describe('requests', () => {
698
766
  body: 'test',
699
767
  type: contentType,
700
768
  schema: 'stream/ba',
701
- expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries(new Uint8Array([116, 101, 115, 116]).entries()) }
769
+ expected: {
770
+ status: 400,
771
+ },
702
772
  },
703
773
  {
704
774
  body: 'test',
705
775
  type: contentType,
706
776
  schema: 'stream/str',
707
- expected: { status: 200, type: 'AsyncIterator', resp: 'test' }
777
+ expected: { status: 200, type: 'AsyncIterator', resp: 'test' },
708
778
  },
709
779
  { body: 'test', type: contentType, schema: 'stream/form', expected: { status: 400 } },
710
- { body: 'test', type: contentType, schema: 'stream/mp', expected: { status: 400 } }
780
+ { body: 'test', type: contentType, schema: 'stream/mp', expected: { status: 400 } },
711
781
  ]
712
782
 
713
783
  for (let { body, type, schema, expected } of cases) {
@@ -715,8 +785,8 @@ describe('requests', () => {
715
785
  method: 'POST',
716
786
  body,
717
787
  headers: {
718
- ...(type ? { 'content-type': type } : {})
719
- }
788
+ ...(type ? { 'content-type': type } : {}),
789
+ },
720
790
  })
721
791
 
722
792
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -734,7 +804,7 @@ describe('requests', () => {
734
804
  const objBody = { string: 'text', number: '42', boolean: 'true', 'encoded=': '=' }
735
805
  const cases: Case[] = [
736
806
  { body: strBody, type: contentType, schema: 'none', expected: { status: 200, type: 'object', resp: objBody } },
737
- { body: strBody, type: contentType, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: strBody } },
807
+ { body: strBody, type: contentType, schema: 'ba', expected: { status: 400 } },
738
808
  { body: strBody, type: contentType, schema: 'bool', expected: { status: 400 } },
739
809
  { body: strBody, type: contentType, schema: 'num', expected: { status: 400 } },
740
810
  { body: strBody, type: contentType, schema: 'str', expected: { status: 400 } },
@@ -746,21 +816,23 @@ describe('requests', () => {
746
816
  body: strBody,
747
817
  type: contentType,
748
818
  schema: 'stream/ba',
749
- expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries(Uint8Array.from(strBody, c => c.charCodeAt(0)).entries()) }
819
+ expected: {
820
+ status: 400,
821
+ },
750
822
  },
751
823
  {
752
824
  body: strBody,
753
825
  type: contentType,
754
826
  schema: 'stream/str',
755
- expected: { status: 200, type: 'AsyncIterator', resp: strBody }
827
+ expected: { status: 400 },
756
828
  },
757
829
  {
758
830
  body: strBody,
759
831
  type: contentType,
760
832
  schema: 'stream/form',
761
- expected: { status: 200, type: 'object', resp: objBody }
833
+ expected: { status: 200, type: 'object', resp: objBody },
762
834
  },
763
- { body: strBody, type: contentType, schema: 'stream/mp', expected: { status: 400 } }
835
+ { body: strBody, type: contentType, schema: 'stream/mp', expected: { status: 400 } },
764
836
  ]
765
837
 
766
838
  for (let { body, type, schema, expected } of cases) {
@@ -768,8 +840,8 @@ describe('requests', () => {
768
840
  method: 'POST',
769
841
  body,
770
842
  headers: {
771
- ...(type ? { 'content-type': type } : {})
772
- }
843
+ ...(type ? { 'content-type': type } : {}),
844
+ },
773
845
  })
774
846
 
775
847
  let respBody = (await resp.json()) as { type: string; content: any }
@@ -787,33 +859,27 @@ describe('requests', () => {
787
859
  string: {
788
860
  content: 'text',
789
861
  headers: {
790
- name: 'string'
791
- }
862
+ name: 'string',
863
+ },
792
864
  },
793
865
  number: {
794
866
  content: '42',
795
867
  headers: {
796
- name: 'number'
797
- }
868
+ name: 'number',
869
+ },
798
870
  },
799
871
  boolean: {
800
872
  content: 'true',
801
873
  headers: {
802
- name: 'boolean'
803
- }
804
- }
874
+ name: 'boolean',
875
+ },
876
+ },
805
877
  }
806
- const objRespStrRgx = new RegExp(
807
- '^---WebkitFormBoundary[0-9a-f]{32}\r\nContent-Disposition: form-data; name="string"\r\n\r\ntext\r\n' +
808
- '---WebkitFormBoundary[0-9a-f]{32}\r\nContent-Disposition: form-data; name="number"\r\n\r\n42\r\n' +
809
- '---WebkitFormBoundary[0-9a-f]{32}\r\nContent-Disposition: form-data; name="boolean"\r\n\r\ntrue\r\n' +
810
- '---WebkitFormBoundary[0-9a-f]{32}--\r\n$'
811
- )
812
878
  const form = formdata(objBody)
813
879
 
814
880
  const cases: Case[] = [
815
881
  { body: form, schema: 'none', expected: { status: 200, type: 'object', resp: objResp } },
816
- { body: form, schema: 'ba', expected: { status: 200, type: 'byteArray', resp: objRespStrRgx } },
882
+ { body: form, schema: 'ba', expected: { status: 400 } },
817
883
  { body: form, schema: 'bool', expected: { status: 400 } },
818
884
  { body: form, schema: 'num', expected: { status: 400 } },
819
885
  { body: form, schema: 'str', expected: { status: 400 } },
@@ -824,10 +890,10 @@ describe('requests', () => {
824
890
  {
825
891
  body: form,
826
892
  schema: 'stream/str',
827
- expected: { status: 200, type: 'AsyncIterator', resp: objRespStrRgx }
893
+ expected: { status: 400 },
828
894
  },
829
895
  { body: form, schema: 'stream/form', expected: { status: 400 } },
830
- { body: form, schema: 'stream/mp', expected: { status: 200, type: 'object', resp: objResp } }
896
+ { body: form, schema: 'stream/mp', expected: { status: 200, type: 'object', resp: objResp } },
831
897
  ]
832
898
 
833
899
  for (let { body, type, schema, expected } of cases) {
@@ -835,8 +901,8 @@ describe('requests', () => {
835
901
  method: 'POST',
836
902
  body,
837
903
  headers: {
838
- ...(type ? { 'content-type': type } : {})
839
- }
904
+ ...(type ? { 'content-type': type } : {}),
905
+ },
840
906
  })
841
907
 
842
908
  let respBody = (await resp.json()) as { type: string; content: any }