@unito/integration-sdk 2.4.4 → 3.0.1

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.
@@ -50,7 +50,7 @@ describe('Provider', () => {
50
50
  it('get', async context => {
51
51
  const response = new Response('{"data": "value"}', {
52
52
  status: 200,
53
- headers: { 'Content-Type': 'application/json' },
53
+ headers: new Headers({ 'Content-Type': 'application/json' }),
54
54
  });
55
55
 
56
56
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -77,13 +77,17 @@ describe('Provider', () => {
77
77
  },
78
78
  },
79
79
  ]);
80
- assert.deepEqual(actualResponse, { status: 200, headers: response.headers, body: { data: 'value' } });
80
+ assert.deepEqual(actualResponse, {
81
+ status: 200,
82
+ headers: Object.fromEntries(response.headers.entries()),
83
+ body: { data: 'value' },
84
+ });
81
85
  });
82
86
 
83
87
  it('accepts text/html type response', async context => {
84
88
  const response = new Response('', {
85
89
  status: 200,
86
- headers: { 'Content-Type': 'text/html; charset=UTF-8' },
90
+ headers: new Headers({ 'Content-Type': 'text/html; charset=UTF-8' }),
87
91
  });
88
92
 
89
93
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -112,13 +116,17 @@ describe('Provider', () => {
112
116
  },
113
117
  ]);
114
118
 
115
- assert.deepEqual(actualResponse, { status: 200, headers: response.headers, body: '' });
119
+ assert.deepEqual(actualResponse, {
120
+ status: 200,
121
+ headers: Object.fromEntries(response.headers.entries()),
122
+ body: '',
123
+ });
116
124
  });
117
125
 
118
126
  it('accepts application/schema+json type response', async context => {
119
127
  const response = new Response('{"data": "value"}', {
120
128
  status: 200,
121
- headers: { 'Content-Type': 'application/schema+json; charset=UTF-8' },
129
+ headers: new Headers({ 'Content-Type': 'application/schema+json; charset=UTF-8' }),
122
130
  });
123
131
 
124
132
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -147,13 +155,17 @@ describe('Provider', () => {
147
155
  },
148
156
  ]);
149
157
 
150
- assert.deepEqual(actualResponse, { status: 200, headers: response.headers, body: { data: 'value' } });
158
+ assert.deepEqual(actualResponse, {
159
+ status: 200,
160
+ headers: Object.fromEntries(response.headers.entries()),
161
+ body: { data: 'value' },
162
+ });
151
163
  });
152
164
 
153
165
  it('accepts application/swagger+json type response', async context => {
154
166
  const response = new Response('{"data": "value"}', {
155
167
  status: 200,
156
- headers: { 'Content-Type': 'application/swagger+json; charset=UTF-8' },
168
+ headers: new Headers({ 'Content-Type': 'application/swagger+json; charset=UTF-8' }),
157
169
  });
158
170
 
159
171
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -182,13 +194,17 @@ describe('Provider', () => {
182
194
  },
183
195
  ]);
184
196
 
185
- assert.deepEqual(actualResponse, { status: 200, headers: response.headers, body: { data: 'value' } });
197
+ assert.deepEqual(actualResponse, {
198
+ status: 200,
199
+ headers: Object.fromEntries(response.headers.entries()),
200
+ body: { data: 'value' },
201
+ });
186
202
  });
187
203
 
188
204
  it('accepts application/vnd.oracle.resource+json type response', async context => {
189
205
  const response = new Response('{"data": "value"}', {
190
206
  status: 200,
191
- headers: { 'Content-Type': 'application/vnd.oracle.resource+json; type=collection; charset=UTF-8' },
207
+ headers: new Headers({ 'Content-Type': 'application/vnd.oracle.resource+json; type=collection; charset=UTF-8' }),
192
208
  });
193
209
 
194
210
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -217,13 +233,17 @@ describe('Provider', () => {
217
233
  },
218
234
  ]);
219
235
 
220
- assert.deepEqual(actualResponse, { status: 200, headers: response.headers, body: { data: 'value' } });
236
+ assert.deepEqual(actualResponse, {
237
+ status: 200,
238
+ headers: Object.fromEntries(response.headers.entries()),
239
+ body: { data: 'value' },
240
+ });
221
241
  });
222
242
 
223
243
  it('returns the raw response body if specified', async context => {
224
244
  const response = new Response(`IMAGINE A HUGE PAYLOAD`, {
225
245
  status: 200,
226
- headers: { 'Content-Type': 'image/png' },
246
+ headers: new Headers({ 'Content-Type': 'image/png' }),
227
247
  });
228
248
 
229
249
  context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -246,7 +266,7 @@ describe('Provider', () => {
246
266
  it('gets an endpoint which is an absolute url', async context => {
247
267
  const response = new Response('{"data": "value"}', {
248
268
  status: 200,
249
- headers: { 'Content-Type': 'application/json' },
269
+ headers: new Headers({ 'Content-Type': 'application/json' }),
250
270
  });
251
271
 
252
272
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -271,13 +291,17 @@ describe('Provider', () => {
271
291
  },
272
292
  },
273
293
  ]);
274
- assert.deepEqual(actualResponse, { status: 200, headers: response.headers, body: { data: 'value' } });
294
+ assert.deepEqual(actualResponse, {
295
+ status: 200,
296
+ headers: Object.fromEntries(response.headers.entries()),
297
+ body: { data: 'value' },
298
+ });
275
299
  });
276
300
 
277
301
  it('gets on provider url', async context => {
278
302
  const response = new Response('{"data": "value"}', {
279
303
  status: 200,
280
- headers: { 'Content-Type': 'application/json' },
304
+ headers: new Headers({ 'Content-Type': 'application/json' }),
281
305
  });
282
306
 
283
307
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -302,13 +326,17 @@ describe('Provider', () => {
302
326
  },
303
327
  },
304
328
  ]);
305
- assert.deepEqual(actualResponse, { status: 200, headers: response.headers, body: { data: 'value' } });
329
+ assert.deepEqual(actualResponse, {
330
+ status: 200,
331
+ headers: Object.fromEntries(response.headers.entries()),
332
+ body: { data: 'value' },
333
+ });
306
334
  });
307
335
 
308
336
  it('post with url encoded body', async context => {
309
337
  const response = new Response('{"data": "value"}', {
310
338
  status: 201,
311
- headers: { 'Content-Type': 'application/json' },
339
+ headers: new Headers({ 'Content-Type': 'application/json' }),
312
340
  });
313
341
 
314
342
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -342,13 +370,17 @@ describe('Provider', () => {
342
370
  },
343
371
  },
344
372
  ]);
345
- assert.deepEqual(actualResponse, { status: 201, headers: response.headers, body: { data: 'value' } });
373
+ assert.deepEqual(actualResponse, {
374
+ status: 201,
375
+ headers: Object.fromEntries(response.headers.entries()),
376
+ body: { data: 'value' },
377
+ });
346
378
  });
347
379
 
348
380
  it('accepts an array as body for post request', async context => {
349
381
  const response = new Response('{"data": "value"}', {
350
382
  status: 201,
351
- headers: { 'Content-Type': 'application/json' },
383
+ headers: new Headers({ 'Content-Type': 'application/json' }),
352
384
  });
353
385
 
354
386
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -383,13 +415,17 @@ describe('Provider', () => {
383
415
  },
384
416
  },
385
417
  ]);
386
- assert.deepEqual(actualResponse, { status: 201, headers: response.headers, body: { data: 'value' } });
418
+ assert.deepEqual(actualResponse, {
419
+ status: 201,
420
+ headers: Object.fromEntries(response.headers.entries()),
421
+ body: { data: 'value' },
422
+ });
387
423
  });
388
424
 
389
425
  it('put with json body', async context => {
390
426
  const response = new Response('{"data": "value"}', {
391
427
  status: 201,
392
- headers: { 'Content-Type': 'application/json' },
428
+ headers: new Headers({ 'Content-Type': 'application/json' }),
393
429
  });
394
430
 
395
431
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -424,13 +460,17 @@ describe('Provider', () => {
424
460
  },
425
461
  },
426
462
  ]);
427
- assert.deepEqual(actualResponse, { status: 201, headers: response.headers, body: { data: 'value' } });
463
+ assert.deepEqual(actualResponse, {
464
+ status: 201,
465
+ headers: Object.fromEntries(response.headers.entries()),
466
+ body: { data: 'value' },
467
+ });
428
468
  });
429
469
 
430
470
  it('putBuffer with Buffer body', async context => {
431
471
  const response = new Response('{"data": "value"}', {
432
472
  status: 201,
433
- headers: { 'Content-Type': 'application/json' },
473
+ headers: new Headers({ 'Content-Type': 'application/json' }),
434
474
  });
435
475
 
436
476
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -461,13 +501,17 @@ describe('Provider', () => {
461
501
  },
462
502
  },
463
503
  ]);
464
- assert.deepEqual(actualResponse, { status: 201, headers: response.headers, body: { data: 'value' } });
504
+ assert.deepEqual(actualResponse, {
505
+ status: 201,
506
+ headers: Object.fromEntries(response.headers.entries()),
507
+ body: { data: 'value' },
508
+ });
465
509
  });
466
510
 
467
511
  it('patch with query params', async context => {
468
512
  const response = new Response('{"data": "value"}', {
469
513
  status: 201,
470
- headers: { 'Content-Type': 'application/json' },
514
+ headers: new Headers({ 'Content-Type': 'application/json' }),
471
515
  });
472
516
 
473
517
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -502,13 +546,17 @@ describe('Provider', () => {
502
546
  },
503
547
  },
504
548
  ]);
505
- assert.deepEqual(actualResponse, { status: 201, headers: response.headers, body: { data: 'value' } });
549
+ assert.deepEqual(actualResponse, {
550
+ status: 201,
551
+ headers: Object.fromEntries(response.headers.entries()),
552
+ body: { data: 'value' },
553
+ });
506
554
  });
507
555
 
508
556
  it('delete', async context => {
509
557
  const response = new Response(undefined, {
510
558
  status: 204,
511
- headers: { 'Content-Type': 'application/json' },
559
+ headers: new Headers({ 'Content-Type': 'application/json' }),
512
560
  });
513
561
 
514
562
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -535,13 +583,17 @@ describe('Provider', () => {
535
583
  },
536
584
  },
537
585
  ]);
538
- assert.deepEqual(actualResponse, { status: 204, headers: response.headers, body: undefined });
586
+ assert.deepEqual(actualResponse, {
587
+ status: 204,
588
+ headers: Object.fromEntries(response.headers.entries()),
589
+ body: undefined,
590
+ });
539
591
  });
540
592
 
541
593
  it('deleteWithBody', async context => {
542
594
  const response = new Response('{"success": true}', {
543
595
  status: 200,
544
- headers: { 'Content-Type': 'application/json' },
596
+ headers: new Headers({ 'Content-Type': 'application/json' }),
545
597
  });
546
598
 
547
599
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -574,7 +626,11 @@ describe('Provider', () => {
574
626
  },
575
627
  },
576
628
  ]);
577
- assert.deepEqual(actualResponse, { status: 200, headers: response.headers, body: { success: true } });
629
+ assert.deepEqual(actualResponse, {
630
+ status: 200,
631
+ headers: Object.fromEntries(response.headers.entries()),
632
+ body: { success: true },
633
+ });
578
634
  });
579
635
 
580
636
  it('uses rate limiter if provided', async context => {
@@ -595,7 +651,7 @@ describe('Provider', () => {
595
651
 
596
652
  const response = new Response(undefined, {
597
653
  status: 204,
598
- headers: { 'Content-Type': 'application/json' },
654
+ headers: new Headers({ 'Content-Type': 'application/json' }),
599
655
  });
600
656
 
601
657
  const fetchMock = context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -626,7 +682,11 @@ describe('Provider', () => {
626
682
  },
627
683
  },
628
684
  ]);
629
- assert.deepEqual(actualResponse, { status: 204, headers: response.headers, body: undefined });
685
+ assert.deepEqual(actualResponse, {
686
+ status: 204,
687
+ headers: Object.fromEntries(response.headers.entries()),
688
+ body: undefined,
689
+ });
630
690
  });
631
691
 
632
692
  it('uses custom error handler if provided', async context => {
@@ -648,7 +708,7 @@ describe('Provider', () => {
648
708
 
649
709
  const response = new Response(undefined, {
650
710
  status: 400,
651
- headers: { 'Content-Type': 'application/json' },
711
+ headers: new Headers({ 'Content-Type': 'application/json' }),
652
712
  });
653
713
 
654
714
  context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -695,7 +755,7 @@ describe('Provider', () => {
695
755
 
696
756
  const response = new Response(undefined, {
697
757
  status: 400,
698
- headers: { 'Content-Type': 'application/json' },
758
+ headers: new Headers({ 'Content-Type': 'application/json' }),
699
759
  });
700
760
 
701
761
  context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -736,7 +796,7 @@ describe('Provider', () => {
736
796
 
737
797
  const response = new Response(undefined, {
738
798
  status: 404,
739
- headers: { 'Content-Type': 'application/json' },
799
+ headers: new Headers({ 'Content-Type': 'application/json' }),
740
800
  });
741
801
 
742
802
  context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -762,7 +822,7 @@ describe('Provider', () => {
762
822
  it('returns valid json response', async context => {
763
823
  const response = new Response(`{ "validJson": true }`, {
764
824
  status: 200,
765
- headers: { 'Content-Type': 'application/json;charset=utf-8' },
825
+ headers: new Headers({ 'Content-Type': 'application/json;charset=utf-8' }),
766
826
  });
767
827
 
768
828
  context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -798,7 +858,7 @@ describe('Provider', () => {
798
858
  it('returns streamable response on streaming get calls', async context => {
799
859
  const response = new Response(`IMAGINE A HUGE PAYLOAD`, {
800
860
  status: 200,
801
- headers: { 'Content-Type': 'video/mp4' },
861
+ headers: new Headers({ 'Content-Type': 'video/mp4' }),
802
862
  });
803
863
 
804
864
  context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -816,7 +876,7 @@ describe('Provider', () => {
816
876
  it('returns successfully on unexpected content-type response with no body', async context => {
817
877
  const response = new Response(null, {
818
878
  status: 201,
819
- headers: { 'Content-Type': 'html/text' },
879
+ headers: new Headers({ 'Content-Type': 'html/text' }),
820
880
  });
821
881
 
822
882
  context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -833,14 +893,14 @@ describe('Provider', () => {
833
893
 
834
894
  assert.ok(providerResponse);
835
895
  assert.strictEqual(providerResponse.status, response.status);
836
- assert.strictEqual(providerResponse.headers, response.headers);
896
+ assert.deepEqual(providerResponse.headers, Object.fromEntries(response.headers.entries()));
837
897
  assert.strictEqual(providerResponse.body, undefined);
838
898
  });
839
899
 
840
900
  it('throws on invalid json response', async context => {
841
901
  const response = new Response('{invalidJSON}', {
842
902
  status: 200,
843
- headers: { 'Content-Type': 'application/json' },
903
+ headers: new Headers({ 'Content-Type': 'application/json' }),
844
904
  });
845
905
 
846
906
  context.mock.method(global, 'fetch', () => Promise.resolve(response));
@@ -864,7 +924,7 @@ describe('Provider', () => {
864
924
  it('throws on unexpected content-type response', async context => {
865
925
  const response = new Response('text', {
866
926
  status: 200,
867
- headers: { 'Content-Type': 'application/text' },
927
+ headers: new Headers({ 'Content-Type': 'application/text' }),
868
928
  });
869
929
 
870
930
  context.mock.method(global, 'fetch', () => Promise.resolve(response));