@ama-sdk/core 12.1.8 → 12.1.11
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/cjs/clients/api-angular-client.js +13 -18
- package/cjs/clients/api-fetch-client.js +16 -21
- package/cjs/fwk/api.helpers.js +11 -11
- package/cjs/fwk/date.js +5 -5
- package/cjs/fwk/errors.js +7 -7
- package/cjs/fwk/mocks/alf-mock-adapter.js +58 -60
- package/cjs/fwk/mocks/base-mock-adapter.js +15 -19
- package/cjs/fwk/mocks/helpers.js +3 -3
- package/cjs/fwk/param-serialization.js +6 -6
- package/cjs/fwk/reviver.js +4 -4
- package/cjs/plugins/abort/abort.spec.js +83 -81
- package/cjs/plugins/additional-params/additional-params.request.js +18 -25
- package/cjs/plugins/additional-params/additional-params.spec.js +194 -186
- package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
- package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
- package/cjs/plugins/api-key/api-key.request.js +12 -19
- package/cjs/plugins/api-key/api-key.spec.js +50 -50
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +25 -36
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
- package/cjs/plugins/client-facts/client-facts.request.js +18 -25
- package/cjs/plugins/client-facts/client-facts.spec.js +218 -208
- package/cjs/plugins/concurrent/concurrent.fetch.js +12 -20
- package/cjs/plugins/concurrent/concurrent.spec.js +99 -99
- package/cjs/plugins/custom-info/custom-info.spec.js +90 -90
- package/cjs/plugins/fetch-cache/fetch-cache.spec.js +100 -98
- package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
- package/cjs/plugins/json-token/json-token.spec.js +109 -107
- package/cjs/plugins/keepalive/keepalive.request.js +7 -12
- package/cjs/plugins/keepalive/keepalive.spec.js +32 -34
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +11 -23
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
- package/cjs/plugins/mock-intercept/mock-intercept.angular.js +94 -100
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
- package/cjs/plugins/mock-intercept/mock-intercept.interface.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.request.js +12 -19
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +245 -237
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +11 -18
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +19 -27
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
- package/cjs/plugins/raw-response-info/raw-response-info.spec.js +67 -67
- package/cjs/plugins/retry/retry.fetch.js +18 -27
- package/cjs/plugins/retry/retry.spec.js +233 -225
- package/cjs/plugins/reviver/reviver.spec.js +88 -86
- package/cjs/plugins/session-id/session-id.spec.js +98 -94
- package/cjs/plugins/si-token/si-token.spec.js +27 -29
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
- package/cjs/plugins/timeout/timeout.fetch.js +16 -22
- package/cjs/plugins/timeout/timeout.spec.js +211 -205
- package/cjs/plugins/url-rewrite/url-rewrite.request.js +9 -16
- package/cjs/plugins/url-rewrite/url-rewrite.spec.js +48 -48
- package/cjs/plugins/wait-for/wait-for.fetch.js +19 -29
- package/cjs/plugins/wait-for/wait-for.spec.js +211 -203
- package/cjs/utils/crypto.js +15 -27
- package/cjs/utils/generic-api.js +9 -14
- package/cjs/utils/json-token.js +19 -26
- package/cjs/utils/json-token.spec.js +495 -497
- package/cjs/utils/mime-types.js +3 -3
- package/esm2015/clients/api-angular-client.js +13 -18
- package/esm2015/clients/api-fetch-client.js +16 -21
- package/esm2015/fwk/mocks/alf-mock-adapter.js +58 -60
- package/esm2015/fwk/mocks/base-mock-adapter.js +15 -19
- package/esm2015/plugins/abort/abort.spec.js +83 -81
- package/esm2015/plugins/additional-params/additional-params.request.js +15 -22
- package/esm2015/plugins/additional-params/additional-params.spec.js +194 -186
- package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
- package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
- package/esm2015/plugins/api-key/api-key.request.js +12 -19
- package/esm2015/plugins/api-key/api-key.spec.js +50 -50
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +21 -32
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
- package/esm2015/plugins/client-facts/client-facts.request.js +15 -22
- package/esm2015/plugins/client-facts/client-facts.spec.js +218 -208
- package/esm2015/plugins/concurrent/concurrent.fetch.js +12 -20
- package/esm2015/plugins/concurrent/concurrent.spec.js +99 -99
- package/esm2015/plugins/custom-info/custom-info.spec.js +90 -90
- package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +100 -98
- package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
- package/esm2015/plugins/json-token/json-token.spec.js +109 -107
- package/esm2015/plugins/keepalive/keepalive.request.js +7 -12
- package/esm2015/plugins/keepalive/keepalive.spec.js +32 -34
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +8 -20
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
- package/esm2015/plugins/mock-intercept/mock-intercept.angular.js +94 -100
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
- package/esm2015/plugins/mock-intercept/mock-intercept.request.js +12 -19
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +245 -237
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +11 -18
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +15 -23
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
- package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +67 -67
- package/esm2015/plugins/retry/retry.fetch.js +18 -27
- package/esm2015/plugins/retry/retry.spec.js +233 -225
- package/esm2015/plugins/reviver/reviver.spec.js +88 -86
- package/esm2015/plugins/session-id/session-id.spec.js +98 -94
- package/esm2015/plugins/si-token/si-token.spec.js +27 -29
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
- package/esm2015/plugins/timeout/timeout.fetch.js +13 -19
- package/esm2015/plugins/timeout/timeout.spec.js +211 -205
- package/esm2015/plugins/url-rewrite/url-rewrite.request.js +9 -16
- package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +48 -48
- package/esm2015/plugins/wait-for/wait-for.fetch.js +19 -29
- package/esm2015/plugins/wait-for/wait-for.spec.js +211 -203
- package/esm2015/utils/crypto.js +8 -20
- package/esm2015/utils/generic-api.js +9 -14
- package/esm2015/utils/json-token.js +10 -17
- package/esm2015/utils/json-token.spec.js +495 -497
- package/package.json +6 -6
|
@@ -41,7 +41,7 @@ function _define_property(obj, key, value) {
|
|
|
41
41
|
return obj;
|
|
42
42
|
}
|
|
43
43
|
function _ts_generator(thisArg, body) {
|
|
44
|
-
var f, y, t,
|
|
44
|
+
var f, y, t, _ = {
|
|
45
45
|
label: 0,
|
|
46
46
|
sent: function() {
|
|
47
47
|
if (t[0] & 1) throw t[1];
|
|
@@ -49,12 +49,8 @@ function _ts_generator(thisArg, body) {
|
|
|
49
49
|
},
|
|
50
50
|
trys: [],
|
|
51
51
|
ops: []
|
|
52
|
-
};
|
|
53
|
-
return g = {
|
|
54
|
-
next: verb(0),
|
|
55
|
-
"throw": verb(1),
|
|
56
|
-
"return": verb(2)
|
|
57
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
52
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
53
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
58
54
|
return this;
|
|
59
55
|
}), g;
|
|
60
56
|
function verb(n) {
|
|
@@ -67,7 +63,7 @@ function _ts_generator(thisArg, body) {
|
|
|
67
63
|
}
|
|
68
64
|
function step(op) {
|
|
69
65
|
if (f) throw new TypeError("Generator is already executing.");
|
|
70
|
-
while(_)try {
|
|
66
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
71
67
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
72
68
|
if (y = 0, t) op = [
|
|
73
69
|
op[0] & 2,
|
|
@@ -169,114 +165,120 @@ describe('Mock intercept', function() {
|
|
|
169
165
|
return jest.clearAllMocks();
|
|
170
166
|
});
|
|
171
167
|
describe('request plugin', function() {
|
|
172
|
-
it('should do nothing if disabled is true',
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
168
|
+
it('should do nothing if disabled is true', function() {
|
|
169
|
+
return _async_to_generator(function() {
|
|
170
|
+
var plugin, originalRequest, loaded;
|
|
171
|
+
return _ts_generator(this, function(_state) {
|
|
172
|
+
switch(_state.label){
|
|
173
|
+
case 0:
|
|
174
|
+
plugin = new MockInterceptRequest({
|
|
175
|
+
disabled: true,
|
|
176
|
+
adapter: testMockAdapter
|
|
177
|
+
});
|
|
178
|
+
originalRequest = {
|
|
179
|
+
method: 'get',
|
|
180
|
+
headers: new Headers({
|
|
181
|
+
test: 'true'
|
|
182
|
+
}),
|
|
183
|
+
basePath: 'myurl'
|
|
184
|
+
};
|
|
185
|
+
loaded = plugin.load();
|
|
186
|
+
return [
|
|
187
|
+
4,
|
|
188
|
+
loaded.transform(originalRequest)
|
|
189
|
+
];
|
|
190
|
+
case 1:
|
|
191
|
+
expect.apply(void 0, [
|
|
192
|
+
_state.sent()
|
|
193
|
+
]).toEqual(originalRequest);
|
|
194
|
+
expect(initializeSpy).toHaveBeenCalled();
|
|
195
|
+
return [
|
|
196
|
+
2
|
|
197
|
+
];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
})();
|
|
201
|
+
});
|
|
202
|
+
it('should not stringify provided api', function() {
|
|
203
|
+
return _async_to_generator(function() {
|
|
204
|
+
var plugin, loaded, originalRequest;
|
|
205
|
+
return _ts_generator(this, function(_state) {
|
|
206
|
+
switch(_state.label){
|
|
207
|
+
case 0:
|
|
208
|
+
plugin = new MockInterceptRequest({
|
|
209
|
+
disabled: false,
|
|
210
|
+
adapter: testMockAdapter
|
|
211
|
+
});
|
|
212
|
+
loaded = plugin.load();
|
|
213
|
+
originalRequest = {
|
|
214
|
+
method: 'get',
|
|
215
|
+
headers: new Headers({
|
|
216
|
+
test: 'true'
|
|
217
|
+
}),
|
|
218
|
+
basePath: 'myurl',
|
|
219
|
+
api: 'should not exist'
|
|
220
|
+
};
|
|
221
|
+
return [
|
|
222
|
+
4,
|
|
223
|
+
loaded.transform(originalRequest)
|
|
224
|
+
];
|
|
225
|
+
case 1:
|
|
226
|
+
_state.sent();
|
|
227
|
+
expect(originalRequest.headers.has(CUSTOM_MOCK_REQUEST_HEADER)).toBe(true);
|
|
228
|
+
expect(Object.keys(JSON.parse(originalRequest.headers.get(CUSTOM_MOCK_REQUEST_HEADER)))).not.toContainEqual('api');
|
|
229
|
+
return [
|
|
230
|
+
2
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
})();
|
|
235
|
+
});
|
|
236
|
+
it('should intercept the request', function() {
|
|
237
|
+
return _async_to_generator(function() {
|
|
238
|
+
var plugin, originalRequest, loaded, transformed, res, text;
|
|
239
|
+
return _ts_generator(this, function(_state) {
|
|
240
|
+
switch(_state.label){
|
|
241
|
+
case 0:
|
|
242
|
+
// Disabled because Blob URL is not supported on NodeJS
|
|
243
|
+
plugin = new MockInterceptRequest({
|
|
244
|
+
adapter: testMockAdapter
|
|
245
|
+
});
|
|
246
|
+
originalRequest = {
|
|
247
|
+
headers: new Headers({
|
|
248
|
+
test: 'true'
|
|
249
|
+
}),
|
|
250
|
+
basePath: 'myurl',
|
|
251
|
+
method: 'PATCH'
|
|
252
|
+
};
|
|
253
|
+
loaded = plugin.load();
|
|
254
|
+
return [
|
|
255
|
+
4,
|
|
256
|
+
loaded.transform(originalRequest)
|
|
257
|
+
];
|
|
258
|
+
case 1:
|
|
259
|
+
transformed = _state.sent();
|
|
260
|
+
return [
|
|
261
|
+
4,
|
|
262
|
+
fetch(transformed.basePath, transformed)
|
|
263
|
+
];
|
|
264
|
+
case 2:
|
|
265
|
+
res = _state.sent();
|
|
266
|
+
return [
|
|
267
|
+
4,
|
|
268
|
+
res.text()
|
|
269
|
+
];
|
|
270
|
+
case 3:
|
|
271
|
+
text = _state.sent();
|
|
272
|
+
expect(getMockSpy).toHaveBeenCalled();
|
|
273
|
+
expect(text).toBe(JSON.stringify(testMock.mockData));
|
|
274
|
+
expect(initializeSpy).toHaveBeenCalled();
|
|
275
|
+
return [
|
|
276
|
+
2
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
})();
|
|
281
|
+
});
|
|
280
282
|
});
|
|
281
283
|
describe('fetch plugin', function() {
|
|
282
284
|
describe('when using an initialization function', function() {
|
|
@@ -293,148 +295,154 @@ describe('Mock intercept', function() {
|
|
|
293
295
|
adapter: asyncMockAdapter
|
|
294
296
|
});
|
|
295
297
|
});
|
|
296
|
-
it('should call initialize fn',
|
|
297
|
-
|
|
298
|
+
it('should call initialize fn', function() {
|
|
299
|
+
return _async_to_generator(function() {
|
|
300
|
+
var loadedPlugin, testData;
|
|
301
|
+
return _ts_generator(this, function(_state) {
|
|
302
|
+
switch(_state.label){
|
|
303
|
+
case 0:
|
|
304
|
+
loadedPlugin = plugin.load({
|
|
305
|
+
fetchPlugins: [],
|
|
306
|
+
url: 'myurl',
|
|
307
|
+
apiClient: apiClient,
|
|
308
|
+
options: {
|
|
309
|
+
headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
testData = {
|
|
313
|
+
test: true
|
|
314
|
+
};
|
|
315
|
+
return [
|
|
316
|
+
4,
|
|
317
|
+
loadedPlugin.transform(Promise.resolve(testData))
|
|
318
|
+
];
|
|
319
|
+
case 1:
|
|
320
|
+
_state.sent();
|
|
321
|
+
expect(initializeSpy).toHaveBeenCalled();
|
|
322
|
+
expect(getMockSpy).not.toHaveBeenCalled();
|
|
323
|
+
expect(getLatestMockSpy).toHaveBeenCalledWith('testOperation');
|
|
324
|
+
return [
|
|
325
|
+
2
|
|
326
|
+
];
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
})();
|
|
330
|
+
});
|
|
331
|
+
it('should throw if there is no request plugin', function() {
|
|
332
|
+
var config = {
|
|
333
|
+
fetchPlugins: [],
|
|
334
|
+
url: 'myurl',
|
|
335
|
+
apiClient: {
|
|
336
|
+
options: {
|
|
337
|
+
requestPlugins: []
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
options: {
|
|
341
|
+
headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
expect(function() {
|
|
345
|
+
return plugin.load(config);
|
|
346
|
+
}).toThrow();
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
describe('with delay', function() {
|
|
351
|
+
it('should delay the response of the specific number', function() {
|
|
352
|
+
return _async_to_generator(function() {
|
|
353
|
+
var plugin, loadedPlugin, callback, run;
|
|
298
354
|
return _ts_generator(this, function(_state) {
|
|
299
355
|
switch(_state.label){
|
|
300
356
|
case 0:
|
|
357
|
+
plugin = new MockInterceptFetch({
|
|
358
|
+
adapter: testMockAdapter,
|
|
359
|
+
delayTiming: 700
|
|
360
|
+
});
|
|
301
361
|
loadedPlugin = plugin.load({
|
|
302
362
|
fetchPlugins: [],
|
|
303
|
-
url: '
|
|
363
|
+
url: '',
|
|
304
364
|
apiClient: apiClient,
|
|
305
365
|
options: {
|
|
306
366
|
headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
307
367
|
}
|
|
308
368
|
});
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
};
|
|
369
|
+
callback = jest.fn();
|
|
370
|
+
run = loadedPlugin.transform(Promise.resolve({})).then(callback);
|
|
312
371
|
return [
|
|
313
372
|
4,
|
|
314
|
-
|
|
373
|
+
jest.advanceTimersByTimeAsync(699)
|
|
315
374
|
];
|
|
316
375
|
case 1:
|
|
317
376
|
_state.sent();
|
|
318
|
-
expect(
|
|
319
|
-
|
|
320
|
-
|
|
377
|
+
expect(callback).not.toHaveBeenCalled();
|
|
378
|
+
return [
|
|
379
|
+
4,
|
|
380
|
+
jest.advanceTimersByTimeAsync(1)
|
|
381
|
+
];
|
|
382
|
+
case 2:
|
|
383
|
+
_state.sent();
|
|
384
|
+
expect(callback).toHaveBeenCalled();
|
|
385
|
+
return [
|
|
386
|
+
4,
|
|
387
|
+
run
|
|
388
|
+
];
|
|
389
|
+
case 3:
|
|
390
|
+
_state.sent();
|
|
321
391
|
return [
|
|
322
392
|
2
|
|
323
393
|
];
|
|
324
394
|
}
|
|
325
395
|
});
|
|
326
|
-
}));
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
396
|
+
})();
|
|
397
|
+
});
|
|
398
|
+
it('should delay the response based on callback', function() {
|
|
399
|
+
return _async_to_generator(function() {
|
|
400
|
+
var plugin, loadedPlugin, callback, run;
|
|
401
|
+
return _ts_generator(this, function(_state) {
|
|
402
|
+
switch(_state.label){
|
|
403
|
+
case 0:
|
|
404
|
+
plugin = new MockInterceptFetch({
|
|
405
|
+
adapter: testMockAdapter,
|
|
406
|
+
delayTiming: function() {
|
|
407
|
+
return 800;
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
loadedPlugin = plugin.load({
|
|
411
|
+
fetchPlugins: [],
|
|
412
|
+
url: '',
|
|
413
|
+
apiClient: apiClient,
|
|
414
|
+
options: {
|
|
415
|
+
headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
callback = jest.fn();
|
|
419
|
+
run = loadedPlugin.transform(Promise.resolve({})).then(callback);
|
|
420
|
+
return [
|
|
421
|
+
4,
|
|
422
|
+
jest.advanceTimersByTimeAsync(799)
|
|
423
|
+
];
|
|
424
|
+
case 1:
|
|
425
|
+
_state.sent();
|
|
426
|
+
expect(callback).not.toHaveBeenCalled();
|
|
427
|
+
return [
|
|
428
|
+
4,
|
|
429
|
+
jest.advanceTimersByTimeAsync(1)
|
|
430
|
+
];
|
|
431
|
+
case 2:
|
|
432
|
+
_state.sent();
|
|
433
|
+
expect(callback).toHaveBeenCalled();
|
|
434
|
+
return [
|
|
435
|
+
4,
|
|
436
|
+
run
|
|
437
|
+
];
|
|
438
|
+
case 3:
|
|
439
|
+
_state.sent();
|
|
440
|
+
return [
|
|
441
|
+
2
|
|
442
|
+
];
|
|
338
443
|
}
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
return plugin.load(config);
|
|
342
|
-
}).toThrow();
|
|
343
|
-
});
|
|
444
|
+
});
|
|
445
|
+
})();
|
|
344
446
|
});
|
|
345
447
|
});
|
|
346
|
-
describe('with delay', function() {
|
|
347
|
-
it('should delay the response of the specific number', /*#__PURE__*/ _async_to_generator(function() {
|
|
348
|
-
var plugin, loadedPlugin, callback, run;
|
|
349
|
-
return _ts_generator(this, function(_state) {
|
|
350
|
-
switch(_state.label){
|
|
351
|
-
case 0:
|
|
352
|
-
plugin = new MockInterceptFetch({
|
|
353
|
-
adapter: testMockAdapter,
|
|
354
|
-
delayTiming: 700
|
|
355
|
-
});
|
|
356
|
-
loadedPlugin = plugin.load({
|
|
357
|
-
fetchPlugins: [],
|
|
358
|
-
url: '',
|
|
359
|
-
apiClient: apiClient,
|
|
360
|
-
options: {
|
|
361
|
-
headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
callback = jest.fn();
|
|
365
|
-
run = loadedPlugin.transform(Promise.resolve({})).then(callback);
|
|
366
|
-
return [
|
|
367
|
-
4,
|
|
368
|
-
jest.advanceTimersByTimeAsync(699)
|
|
369
|
-
];
|
|
370
|
-
case 1:
|
|
371
|
-
_state.sent();
|
|
372
|
-
expect(callback).not.toHaveBeenCalled();
|
|
373
|
-
return [
|
|
374
|
-
4,
|
|
375
|
-
jest.advanceTimersByTimeAsync(1)
|
|
376
|
-
];
|
|
377
|
-
case 2:
|
|
378
|
-
_state.sent();
|
|
379
|
-
expect(callback).toHaveBeenCalled();
|
|
380
|
-
return [
|
|
381
|
-
4,
|
|
382
|
-
run
|
|
383
|
-
];
|
|
384
|
-
case 3:
|
|
385
|
-
_state.sent();
|
|
386
|
-
return [
|
|
387
|
-
2
|
|
388
|
-
];
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}));
|
|
392
|
-
it('should delay the response based on callback', /*#__PURE__*/ _async_to_generator(function() {
|
|
393
|
-
var plugin, loadedPlugin, callback, run;
|
|
394
|
-
return _ts_generator(this, function(_state) {
|
|
395
|
-
switch(_state.label){
|
|
396
|
-
case 0:
|
|
397
|
-
plugin = new MockInterceptFetch({
|
|
398
|
-
adapter: testMockAdapter,
|
|
399
|
-
delayTiming: function() {
|
|
400
|
-
return 800;
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
loadedPlugin = plugin.load({
|
|
404
|
-
fetchPlugins: [],
|
|
405
|
-
url: '',
|
|
406
|
-
apiClient: apiClient,
|
|
407
|
-
options: {
|
|
408
|
-
headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
callback = jest.fn();
|
|
412
|
-
run = loadedPlugin.transform(Promise.resolve({})).then(callback);
|
|
413
|
-
return [
|
|
414
|
-
4,
|
|
415
|
-
jest.advanceTimersByTimeAsync(799)
|
|
416
|
-
];
|
|
417
|
-
case 1:
|
|
418
|
-
_state.sent();
|
|
419
|
-
expect(callback).not.toHaveBeenCalled();
|
|
420
|
-
return [
|
|
421
|
-
4,
|
|
422
|
-
jest.advanceTimersByTimeAsync(1)
|
|
423
|
-
];
|
|
424
|
-
case 2:
|
|
425
|
-
_state.sent();
|
|
426
|
-
expect(callback).toHaveBeenCalled();
|
|
427
|
-
return [
|
|
428
|
-
4,
|
|
429
|
-
run
|
|
430
|
-
];
|
|
431
|
-
case 3:
|
|
432
|
-
_state.sent();
|
|
433
|
-
return [
|
|
434
|
-
2
|
|
435
|
-
];
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
}));
|
|
439
|
-
});
|
|
440
448
|
});
|
|
@@ -106,7 +106,7 @@ function _object_spread_props(target, source) {
|
|
|
106
106
|
return target;
|
|
107
107
|
}
|
|
108
108
|
function _ts_generator(thisArg, body) {
|
|
109
|
-
var f, y, t,
|
|
109
|
+
var f, y, t, _ = {
|
|
110
110
|
label: 0,
|
|
111
111
|
sent: function() {
|
|
112
112
|
if (t[0] & 1) throw t[1];
|
|
@@ -114,12 +114,8 @@ function _ts_generator(thisArg, body) {
|
|
|
114
114
|
},
|
|
115
115
|
trys: [],
|
|
116
116
|
ops: []
|
|
117
|
-
};
|
|
118
|
-
return g = {
|
|
119
|
-
next: verb(0),
|
|
120
|
-
"throw": verb(1),
|
|
121
|
-
"return": verb(2)
|
|
122
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
117
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
118
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
123
119
|
return this;
|
|
124
120
|
}), g;
|
|
125
121
|
function verb(n) {
|
|
@@ -132,7 +128,7 @@ function _ts_generator(thisArg, body) {
|
|
|
132
128
|
}
|
|
133
129
|
function step(op) {
|
|
134
130
|
if (f) throw new TypeError("Generator is already executing.");
|
|
135
|
-
while(_)try {
|
|
131
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
136
132
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
137
133
|
if (y = 0, t) op = [
|
|
138
134
|
op[0] & 2,
|
|
@@ -322,13 +318,13 @@ import { v4 } from 'uuid';
|
|
|
322
318
|
value: /** @inheritDoc */ function load(context) {
|
|
323
319
|
var _this = this;
|
|
324
320
|
return {
|
|
325
|
-
transform:
|
|
326
|
-
|
|
321
|
+
transform: function(fetchCall) {
|
|
322
|
+
return _async_to_generator(function() {
|
|
327
323
|
var markId, response, exception;
|
|
328
324
|
return _ts_generator(this, function(_state) {
|
|
329
325
|
switch(_state.label){
|
|
330
326
|
case 0:
|
|
331
|
-
markId =
|
|
327
|
+
markId = this.openMark(context.url, context.options);
|
|
332
328
|
_state.label = 1;
|
|
333
329
|
case 1:
|
|
334
330
|
_state.trys.push([
|
|
@@ -343,7 +339,7 @@ import { v4 } from 'uuid';
|
|
|
343
339
|
];
|
|
344
340
|
case 2:
|
|
345
341
|
response = _state.sent();
|
|
346
|
-
|
|
342
|
+
this.closeMark(markId, response);
|
|
347
343
|
return [
|
|
348
344
|
2,
|
|
349
345
|
response
|
|
@@ -351,7 +347,7 @@ import { v4 } from 'uuid';
|
|
|
351
347
|
case 3:
|
|
352
348
|
exception = _state.sent();
|
|
353
349
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access -- type is explicitly `any`
|
|
354
|
-
|
|
350
|
+
this.closeMarkWithError(markId, _instanceof(exception, Error) ? exception : new Error(exception.toString()));
|
|
355
351
|
throw exception;
|
|
356
352
|
case 4:
|
|
357
353
|
return [
|
|
@@ -359,11 +355,8 @@ import { v4 } from 'uuid';
|
|
|
359
355
|
];
|
|
360
356
|
}
|
|
361
357
|
});
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
return _ref.apply(this, arguments);
|
|
365
|
-
};
|
|
366
|
-
}()
|
|
358
|
+
}).call(_this);
|
|
359
|
+
}
|
|
367
360
|
};
|
|
368
361
|
}
|
|
369
362
|
}
|