galbe 0.8.0 → 0.9.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.
@@ -232,7 +232,7 @@ describe('parser', () => {
232
232
  body: {
233
233
  headers: {
234
234
  'neg-number': 'Required',
235
- 'boolean-true': "a is not a valid boolean. Should be 'true' or 'false'"
235
+ 'boolean-true': "Not a valid boolean. Should be 'true' or 'false'"
236
236
  }
237
237
  }
238
238
  }
@@ -259,9 +259,9 @@ describe('parser', () => {
259
259
  status: 400,
260
260
  body: {
261
261
  params: {
262
- p2: 'test is not a valid number',
263
- p3: '42.5 is not a valid integer',
264
- p4: "a is not a valid boolean. Should be 'true' or 'false'"
262
+ p2: 'Not a valid number',
263
+ p3: 'Not a valid integer',
264
+ p4: "Not a valid boolean. Should be 'true' or 'false'"
265
265
  }
266
266
  }
267
267
  }
@@ -291,8 +291,8 @@ describe('parser', () => {
291
291
  status: 400,
292
292
  body: {
293
293
  query: {
294
- p2: 'a is not a valid number',
295
- p3: "0 is not a valid boolean. Should be 'true' or 'false'",
294
+ p2: 'Not a valid number',
295
+ p3: "Not a valid boolean. Should be 'true' or 'false'",
296
296
  p4: 'Required'
297
297
  }
298
298
  }
@@ -400,9 +400,9 @@ describe('parser', () => {
400
400
  resp: {
401
401
  body: {
402
402
  ba: 'Not a valid byteArray',
403
- string: '42 is not a valid string',
404
- number: 'a is not a valid number',
405
- bool: "x is not a valid boolean. Should be 'true' or 'false'",
403
+ string: 'Not a valid string',
404
+ number: 'Not a valid number',
405
+ bool: "Not a valid boolean. Should be 'true' or 'false'",
406
406
  object: 'Expected an object, not an array',
407
407
  array: 'Not a valid array',
408
408
  null: 'Expected null value got ',
@@ -496,10 +496,10 @@ describe('parser', () => {
496
496
  resp: {
497
497
  body: {
498
498
  string: 'Multiple values found',
499
- number: 'aaa is not a valid number',
500
- bool: "1 is not a valid boolean. Should be 'true' or 'false'",
501
- literal: 'y is not a valid value',
502
- union: 'X could not be parsed to any of number, boolean'
499
+ number: 'Not a valid number',
500
+ bool: "Not a valid boolean. Should be 'true' or 'false'",
501
+ literal: 'Not a valid value',
502
+ union: 'Could not be parsed to any of [number, boolean]'
503
503
  }
504
504
  }
505
505
  }
@@ -538,7 +538,7 @@ describe('parser', () => {
538
538
  status: 200,
539
539
  type: 'object',
540
540
  resp: {
541
- ba: new Uint8Array(),
541
+ ba: {},
542
542
  string: '',
543
543
  number: 0,
544
544
  bool: false,
@@ -556,7 +556,7 @@ describe('parser', () => {
556
556
  status: 200,
557
557
  type: 'object',
558
558
  resp: {
559
- ba: new Uint8Array([72, 101, 108, 108, 111]),
559
+ ba: Object.fromEntries(new Uint8Array([72, 101, 108, 108, 111]).entries()),
560
560
  string: 'Mom!',
561
561
  number: 42,
562
562
  bool: true,
@@ -576,7 +576,7 @@ describe('parser', () => {
576
576
  status: 400,
577
577
  type: 'object',
578
578
  resp: {
579
- body: { numArray: 'x is not a valid number' }
579
+ body: { numArray: 'Not a valid number' }
580
580
  }
581
581
  }
582
582
  },
@@ -588,7 +588,7 @@ describe('parser', () => {
588
588
  status: 400,
589
589
  resp: {
590
590
  body: {
591
- literal: 'y is not a valid value'
591
+ literal: 'Not a valid value'
592
592
  }
593
593
  }
594
594
  }
@@ -782,10 +782,10 @@ describe('parser', () => {
782
782
  resp: {
783
783
  body: {
784
784
  string: 'Multiple values found',
785
- number: 'aaa is not a valid number',
786
- bool: "1 is not a valid boolean. Should be 'true' or 'false'",
787
- literal: 'y is not a valid value',
788
- union: 'X could not be parsed to any of: number, boolean'
785
+ number: 'Not a valid number',
786
+ bool: "Not a valid boolean. Should be 'true' or 'false'",
787
+ literal: 'Not a valid value',
788
+ union: 'Could not be parsed to any of [number, boolean]'
789
789
  }
790
790
  }
791
791
  }
@@ -823,7 +823,7 @@ describe('parser', () => {
823
823
  type: 'AsyncIterator',
824
824
  resp: [
825
825
  {
826
- content: new Uint8Array(),
826
+ content: {},
827
827
  headers: {
828
828
  name: 'ba'
829
829
  }
@@ -885,7 +885,7 @@ describe('parser', () => {
885
885
  type: 'AsyncIterator',
886
886
  resp: [
887
887
  {
888
- content: Uint8Array.from('Hello', c => c.charCodeAt(0)),
888
+ content: Object.fromEntries(Uint8Array.from('Hello', c => c.charCodeAt(0)).entries()),
889
889
  headers: {
890
890
  name: 'ba'
891
891
  }
@@ -973,7 +973,7 @@ describe('parser', () => {
973
973
  status: 400,
974
974
  resp: {
975
975
  body: {
976
- number: 'aaa is not a valid number'
976
+ number: 'Not a valid number'
977
977
  }
978
978
  }
979
979
  }
@@ -1199,9 +1199,9 @@ describe('parser', () => {
1199
1199
  status: 400,
1200
1200
  body: {
1201
1201
  query: {
1202
- int: '10 is less or equal to 10',
1203
- num: '42.01 is greater or equal to 42',
1204
- str: ['xxxxxxxxxx length is too large (8 char max)', 'xxxxxxxxxx does not match pattern /^a.*z/']
1202
+ int: 'Is less or equal to 10',
1203
+ num: 'Is greater or equal to 42',
1204
+ str: ['Length is too large (8 char max)', 'Does not match pattern /^a.*z/']
1205
1205
  }
1206
1206
  }
1207
1207
  }
@@ -1239,17 +1239,17 @@ describe('parser', () => {
1239
1239
  )
1240
1240
  expect(type).toBe(
1241
1241
  `{` +
1242
- `'boolean':boolean;` +
1243
- `'byteArray':Uint8Array;` +
1244
- `'number':number;` +
1245
- `'integer':number;` +
1246
- `'string':string;` +
1247
- `'any':any;` +
1248
- `'literal':'literal';` +
1249
- `'array':Array<string>;` +
1250
- `'object':{'foo':string};` +
1251
- `'union':number|string` +
1252
- `}`
1242
+ `'boolean':boolean;` +
1243
+ `'byteArray':Uint8Array;` +
1244
+ `'number':number;` +
1245
+ `'integer':number;` +
1246
+ `'string':string;` +
1247
+ `'any':any;` +
1248
+ `'literal':'literal';` +
1249
+ `'array':Array<string>;` +
1250
+ `'object':{'foo':string};` +
1251
+ `'union':number|string` +
1252
+ `}`
1253
1253
  )
1254
1254
  })
1255
1255
  })
@@ -486,7 +486,7 @@ describe('requests', () => {
486
486
  {
487
487
  body: 'test',
488
488
  schema: 'stream/ba',
489
- expected: { status: 200, type: 'AsyncIterator', resp: new Uint8Array([116, 101, 115, 116]) }
489
+ expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries([116, 101, 115, 116].entries()) }
490
490
  },
491
491
  { body: 'test', schema: 'stream/str', expected: { status: 200, type: 'AsyncIterator', resp: 'test' } },
492
492
  { body: 'test', schema: 'stream/form', expected: { status: 400 } },
@@ -504,9 +504,12 @@ describe('requests', () => {
504
504
 
505
505
  let respBody = (await resp.json()) as { type: string; content: any }
506
506
 
507
+ console.log(respBody)
508
+
507
509
  expect(resp.status).toBe(expected.status)
508
510
  if (expected.type) expect(respBody.type).toEqual(expected.type)
509
511
  if (respBody.type === 'object' && expected.resp === null) expect(respBody.content).toBeNull
512
+ // else if (respBody.type === 'AsyncIterator') expect(new Uint8Array(Object.values(respBody.content))).toEqual(expected.resp)
510
513
  else expect(respBody.content).toEqual(expected.resp)
511
514
  }
512
515
  })
@@ -549,7 +552,7 @@ describe('requests', () => {
549
552
  body: 'test',
550
553
  type: contentType,
551
554
  schema: 'stream/ba',
552
- expected: { status: 200, type: 'AsyncIterator', resp: new Uint8Array([116, 101, 115, 116]) }
555
+ expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries(new Uint8Array([116, 101, 115, 116]).entries()) }
553
556
  },
554
557
  {
555
558
  body: 'test',
@@ -625,7 +628,7 @@ describe('requests', () => {
625
628
  body: 'test',
626
629
  type: contentType,
627
630
  schema: 'stream/ba',
628
- expected: { status: 200, type: 'AsyncIterator', resp: new Uint8Array([116, 101, 115, 116]) }
631
+ expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries(new Uint8Array([116, 101, 115, 116]).entries()) }
629
632
  },
630
633
  {
631
634
  body: 'test',
@@ -695,7 +698,7 @@ describe('requests', () => {
695
698
  body: 'test',
696
699
  type: contentType,
697
700
  schema: 'stream/ba',
698
- expected: { status: 200, type: 'AsyncIterator', resp: new Uint8Array([116, 101, 115, 116]) }
701
+ expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries(new Uint8Array([116, 101, 115, 116]).entries()) }
699
702
  },
700
703
  {
701
704
  body: 'test',
@@ -743,7 +746,7 @@ describe('requests', () => {
743
746
  body: strBody,
744
747
  type: contentType,
745
748
  schema: 'stream/ba',
746
- expected: { status: 200, type: 'AsyncIterator', resp: Uint8Array.from(strBody, c => c.charCodeAt(0)) }
749
+ expected: { status: 200, type: 'AsyncIterator', resp: Object.fromEntries(Uint8Array.from(strBody, c => c.charCodeAt(0)).entries()) }
747
750
  },
748
751
  {
749
752
  body: strBody,
@@ -125,7 +125,7 @@ describe('router', () => {
125
125
  } catch (err: any) {
126
126
  expect(err).toBeInstanceOf(NotFoundError)
127
127
  expect(err.status).toBe(404)
128
- expect(err.payload).toBe('Not found')
128
+ expect(err.payload).toBe('Not Found')
129
129
  }
130
130
 
131
131
  try {
@@ -134,7 +134,7 @@ describe('router', () => {
134
134
  } catch (err: any) {
135
135
  expect(err).toBeInstanceOf(NotFoundError)
136
136
  expect(err.status).toBe(404)
137
- expect(err.payload).toBe('Not found')
137
+ expect(err.payload).toBe('Not Found')
138
138
  }
139
139
  })
140
140