@ama-sdk/client-fetch 12.3.0-prerelease.70 → 12.3.0-prerelease.71
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/api-fetch-client.js +12 -13
- package/cjs/plugins/abort/abort.spec.js +79 -73
- package/cjs/plugins/concurrent/concurrent.fetch.js +8 -12
- package/cjs/plugins/concurrent/concurrent.spec.js +95 -91
- package/cjs/plugins/keepalive/keepalive.request.js +3 -4
- package/cjs/plugins/keepalive/keepalive.spec.js +28 -26
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +11 -14
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +243 -231
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +7 -10
- package/cjs/plugins/retry/retry.fetch.js +14 -19
- package/cjs/plugins/retry/retry.spec.js +229 -217
- package/cjs/plugins/timeout/timeout.fetch.js +9 -11
- package/cjs/plugins/timeout/timeout.spec.js +207 -197
- package/cjs/plugins/wait-for/wait-for.fetch.js +15 -21
- package/cjs/plugins/wait-for/wait-for.spec.js +207 -195
- package/esm2015/api-fetch-client.js +12 -13
- package/esm2015/plugins/abort/abort.spec.js +79 -73
- package/esm2015/plugins/concurrent/concurrent.fetch.js +8 -12
- package/esm2015/plugins/concurrent/concurrent.spec.js +95 -91
- package/esm2015/plugins/keepalive/keepalive.request.js +3 -4
- package/esm2015/plugins/keepalive/keepalive.spec.js +28 -26
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +11 -14
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +243 -231
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +7 -10
- package/esm2015/plugins/retry/retry.fetch.js +14 -19
- package/esm2015/plugins/retry/retry.spec.js +229 -217
- package/esm2015/plugins/timeout/timeout.fetch.js +9 -11
- package/esm2015/plugins/timeout/timeout.spec.js +207 -197
- package/esm2015/plugins/wait-for/wait-for.fetch.js +15 -21
- package/esm2015/plugins/wait-for/wait-for.spec.js +207 -195
- package/package.json +8 -8
package/cjs/api-fetch-client.js
CHANGED
|
@@ -278,7 +278,6 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
278
278
|
{
|
|
279
279
|
key: "getRequestOptions",
|
|
280
280
|
value: /** @inheritdoc */ function getRequestOptions(requestOptionsParameters) {
|
|
281
|
-
var _this = this;
|
|
282
281
|
return _async_to_generator(function() {
|
|
283
282
|
var opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _requestOptionsParameters_api, err;
|
|
284
283
|
return _ts_generator(this, function(_state) {
|
|
@@ -288,7 +287,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
288
287
|
headers: new Headers((0, _core.filterUndefinedValues)(requestOptionsParameters.headers)),
|
|
289
288
|
queryParams: (0, _core.filterUndefinedValues)(requestOptionsParameters.queryParams)
|
|
290
289
|
});
|
|
291
|
-
if (!
|
|
290
|
+
if (!this.options.requestPlugins) return [
|
|
292
291
|
3,
|
|
293
292
|
8
|
|
294
293
|
];
|
|
@@ -301,7 +300,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
301
300
|
7,
|
|
302
301
|
8
|
|
303
302
|
]);
|
|
304
|
-
_iterator =
|
|
303
|
+
_iterator = this.options.requestPlugins[Symbol.iterator]();
|
|
305
304
|
_state.label = 2;
|
|
306
305
|
case 2:
|
|
307
306
|
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
@@ -312,7 +311,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
312
311
|
return [
|
|
313
312
|
4,
|
|
314
313
|
plugin.load({
|
|
315
|
-
logger:
|
|
314
|
+
logger: this.options.logger,
|
|
316
315
|
apiName: (_requestOptionsParameters_api = requestOptionsParameters.api) === null || _requestOptionsParameters_api === void 0 ? void 0 : _requestOptionsParameters_api.apiName
|
|
317
316
|
}).transform(opts)
|
|
318
317
|
];
|
|
@@ -358,7 +357,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
358
357
|
];
|
|
359
358
|
}
|
|
360
359
|
});
|
|
361
|
-
})();
|
|
360
|
+
}).call(this);
|
|
362
361
|
}
|
|
363
362
|
},
|
|
364
363
|
{
|
|
@@ -401,12 +400,12 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
401
400
|
{
|
|
402
401
|
key: "processCall",
|
|
403
402
|
value: function processCall(url, options, apiType, apiName, revivers, operationId) {
|
|
404
|
-
var _this = this;
|
|
405
403
|
return _async_to_generator(function() {
|
|
406
|
-
var response, asyncResponse, root, body, exception, origin, _options_metadata, metadataSignal, controller, loadedPlugins, _loadedPlugins, canStart, isCanceledBy, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, e, reviver, replyPlugins, parsedData, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, pluginRunner, err;
|
|
404
|
+
var _this, response, asyncResponse, root, body, exception, origin, _options_metadata, metadataSignal, controller, loadedPlugins, _loadedPlugins, canStart, isCanceledBy, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, e, reviver, replyPlugins, parsedData, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, pluginRunner, err;
|
|
407
405
|
return _ts_generator(this, function(_state) {
|
|
408
406
|
switch(_state.label){
|
|
409
407
|
case 0:
|
|
408
|
+
_this = this;
|
|
410
409
|
origin = options.headers.get('Origin');
|
|
411
410
|
_state.label = 1;
|
|
412
411
|
case 1:
|
|
@@ -424,9 +423,9 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
424
423
|
return controller.abort();
|
|
425
424
|
});
|
|
426
425
|
loadedPlugins = [];
|
|
427
|
-
if (
|
|
426
|
+
if (this.options.fetchPlugins) {
|
|
428
427
|
;
|
|
429
|
-
(_loadedPlugins = loadedPlugins).push.apply(_loadedPlugins, _to_consumable_array(
|
|
428
|
+
(_loadedPlugins = loadedPlugins).push.apply(_loadedPlugins, _to_consumable_array(this.options.fetchPlugins.map(function(plugin) {
|
|
430
429
|
return plugin.load({
|
|
431
430
|
url: url,
|
|
432
431
|
options: options,
|
|
@@ -446,7 +445,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
446
445
|
case 2:
|
|
447
446
|
canStart = _state.sent();
|
|
448
447
|
isCanceledBy = canStart.indexOf(false);
|
|
449
|
-
asyncResponse = isCanceledBy === -1 ? fetch(url, options) : Promise.reject(new _core.CanceledCallError("Is canceled by the plugin ".concat(isCanceledBy), isCanceledBy,
|
|
448
|
+
asyncResponse = isCanceledBy === -1 ? fetch(url, options) : Promise.reject(new _core.CanceledCallError("Is canceled by the plugin ".concat(isCanceledBy), isCanceledBy, this.options.fetchPlugins[isCanceledBy], {
|
|
450
449
|
apiName: apiName,
|
|
451
450
|
operationId: operationId,
|
|
452
451
|
url: url,
|
|
@@ -524,10 +523,10 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
524
523
|
}
|
|
525
524
|
// eslint-disable-next-line no-console -- `console.error` is supposed to be the default value if the `options` argument is not provided, can be removed in Otter v12.
|
|
526
525
|
reviver = (0, _core.getResponseReviver)(revivers, response, operationId, {
|
|
527
|
-
disableFallback:
|
|
526
|
+
disableFallback: this.options.disableFallback,
|
|
528
527
|
log: console.error
|
|
529
528
|
});
|
|
530
|
-
replyPlugins =
|
|
529
|
+
replyPlugins = this.options.replyPlugins ? this.options.replyPlugins.map(function(plugin) {
|
|
531
530
|
return plugin.load({
|
|
532
531
|
dictionaries: root && root.dictionaries,
|
|
533
532
|
response: response,
|
|
@@ -608,7 +607,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
608
607
|
];
|
|
609
608
|
}
|
|
610
609
|
});
|
|
611
|
-
})();
|
|
610
|
+
}).call(this);
|
|
612
611
|
}
|
|
613
612
|
}
|
|
614
613
|
]);
|
|
@@ -124,77 +124,83 @@ function _ts_generator(thisArg, body) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
describe('Abort Plugin', function() {
|
|
127
|
-
it('should trigger the callback',
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
runner.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
127
|
+
it('should trigger the callback', function() {
|
|
128
|
+
return _async_to_generator(function() {
|
|
129
|
+
var fn, plugin, runner;
|
|
130
|
+
return _ts_generator(this, function(_state) {
|
|
131
|
+
switch(_state.label){
|
|
132
|
+
case 0:
|
|
133
|
+
fn = jest.fn();
|
|
134
|
+
plugin = new _abortfetch.AbortFetch(fn);
|
|
135
|
+
runner = plugin.load({});
|
|
136
|
+
return [
|
|
137
|
+
4,
|
|
138
|
+
runner.transform(Promise.resolve())
|
|
139
|
+
];
|
|
140
|
+
case 1:
|
|
141
|
+
_state.sent();
|
|
142
|
+
expect(fn).toHaveBeenCalled();
|
|
143
|
+
return [
|
|
144
|
+
2
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
})();
|
|
149
|
+
});
|
|
150
|
+
it('should trigger abort signal if true', function() {
|
|
151
|
+
return _async_to_generator(function() {
|
|
152
|
+
var defaultContext, fn, plugin, runner;
|
|
153
|
+
return _ts_generator(this, function(_state) {
|
|
154
|
+
switch(_state.label){
|
|
155
|
+
case 0:
|
|
156
|
+
defaultContext = {
|
|
157
|
+
controller: {
|
|
158
|
+
abort: jest.fn()
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
fn = jest.fn().mockResolvedValue(true);
|
|
162
|
+
plugin = new _abortfetch.AbortFetch(fn);
|
|
163
|
+
runner = plugin.load(defaultContext);
|
|
164
|
+
return [
|
|
165
|
+
4,
|
|
166
|
+
runner.transform(Promise.resolve())
|
|
167
|
+
];
|
|
168
|
+
case 1:
|
|
169
|
+
_state.sent();
|
|
170
|
+
expect(defaultContext.controller.abort).toHaveBeenCalled();
|
|
171
|
+
return [
|
|
172
|
+
2
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
})();
|
|
177
|
+
});
|
|
178
|
+
it('should not trigger abort signal if false', function() {
|
|
179
|
+
return _async_to_generator(function() {
|
|
180
|
+
var defaultContext, fn, plugin, runner;
|
|
181
|
+
return _ts_generator(this, function(_state) {
|
|
182
|
+
switch(_state.label){
|
|
183
|
+
case 0:
|
|
184
|
+
defaultContext = {
|
|
185
|
+
controller: {
|
|
186
|
+
abort: jest.fn()
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
fn = jest.fn().mockResolvedValue(false);
|
|
190
|
+
plugin = new _abortfetch.AbortFetch(fn);
|
|
191
|
+
runner = plugin.load(defaultContext);
|
|
192
|
+
return [
|
|
193
|
+
4,
|
|
194
|
+
runner.transform(Promise.resolve())
|
|
195
|
+
];
|
|
196
|
+
case 1:
|
|
197
|
+
_state.sent();
|
|
198
|
+
expect(defaultContext.controller.abort).not.toHaveBeenCalled();
|
|
199
|
+
return [
|
|
200
|
+
2
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
})();
|
|
205
|
+
});
|
|
200
206
|
});
|
|
@@ -195,20 +195,19 @@ var ConcurrentFetch = /*#__PURE__*/ function() {
|
|
|
195
195
|
value: /** @inheritDoc */ function load(_context) {
|
|
196
196
|
var _this = this;
|
|
197
197
|
this.poolSize++;
|
|
198
|
-
var _this1 = this;
|
|
199
198
|
return {
|
|
200
199
|
canStart: function() {
|
|
201
200
|
return new Promise(function(resolve) {
|
|
202
201
|
return _this.canStart() ? resolve(true) : _this.waitingResolvers.push(resolve);
|
|
203
202
|
});
|
|
204
203
|
},
|
|
205
|
-
transform:
|
|
206
|
-
|
|
204
|
+
transform: function(fetchCall) {
|
|
205
|
+
return _async_to_generator(function() {
|
|
207
206
|
var fetchResponse;
|
|
208
207
|
return _ts_generator(this, function(_state) {
|
|
209
208
|
switch(_state.label){
|
|
210
209
|
case 0:
|
|
211
|
-
|
|
210
|
+
this.pool.push(fetchCall);
|
|
212
211
|
_state.label = 1;
|
|
213
212
|
case 1:
|
|
214
213
|
_state.trys.push([
|
|
@@ -228,11 +227,11 @@ var ConcurrentFetch = /*#__PURE__*/ function() {
|
|
|
228
227
|
fetchResponse
|
|
229
228
|
];
|
|
230
229
|
case 3:
|
|
231
|
-
|
|
230
|
+
this.pool = this.pool.filter(function(call) {
|
|
232
231
|
return call !== fetchCall;
|
|
233
232
|
});
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
this.poolSize--;
|
|
234
|
+
this.unstackResolve();
|
|
236
235
|
return [
|
|
237
236
|
7
|
|
238
237
|
];
|
|
@@ -242,11 +241,8 @@ var ConcurrentFetch = /*#__PURE__*/ function() {
|
|
|
242
241
|
];
|
|
243
242
|
}
|
|
244
243
|
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
return _ref.apply(this, arguments);
|
|
248
|
-
};
|
|
249
|
-
}()
|
|
244
|
+
}).call(_this);
|
|
245
|
+
}
|
|
250
246
|
};
|
|
251
247
|
}
|
|
252
248
|
}
|
|
@@ -124,27 +124,29 @@ function _ts_generator(thisArg, body) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
describe('Concurrent Fetch Plugin', function() {
|
|
127
|
-
it('should start if the limit is not reach',
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
127
|
+
it('should start if the limit is not reach', function() {
|
|
128
|
+
return _async_to_generator(function() {
|
|
129
|
+
var plugin, runner, canStart;
|
|
130
|
+
return _ts_generator(this, function(_state) {
|
|
131
|
+
switch(_state.label){
|
|
132
|
+
case 0:
|
|
133
|
+
plugin = new _concurrentfetch.ConcurrentFetch(3);
|
|
134
|
+
plugin.load({});
|
|
135
|
+
runner = plugin.load({});
|
|
136
|
+
return [
|
|
137
|
+
4,
|
|
138
|
+
runner.canStart()
|
|
139
|
+
];
|
|
140
|
+
case 1:
|
|
141
|
+
canStart = _state.sent();
|
|
142
|
+
expect(canStart).toBe(true);
|
|
143
|
+
return [
|
|
144
|
+
2
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
})();
|
|
149
|
+
});
|
|
148
150
|
it('should retrieve the fetch call in the pool', function() {
|
|
149
151
|
var plugin = new _concurrentfetch.ConcurrentFetch(3);
|
|
150
152
|
var call = new Promise(function(resolve) {
|
|
@@ -162,74 +164,76 @@ describe('Concurrent Fetch Plugin', function() {
|
|
|
162
164
|
void plugin.load({}).transform(test);
|
|
163
165
|
expect(plugin.pool[2]).toBe(test);
|
|
164
166
|
});
|
|
165
|
-
it('should start only when the pool is available',
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
167
|
+
it('should start only when the pool is available', function() {
|
|
168
|
+
return _async_to_generator(function() {
|
|
169
|
+
var plugin, resolves, call0, call1, result, runner1, canStart1, runner2, pCanStart2;
|
|
170
|
+
return _ts_generator(this, function(_state) {
|
|
171
|
+
switch(_state.label){
|
|
172
|
+
case 0:
|
|
173
|
+
plugin = new _concurrentfetch.ConcurrentFetch(2);
|
|
174
|
+
resolves = [
|
|
175
|
+
null,
|
|
176
|
+
null
|
|
177
|
+
];
|
|
178
|
+
call0 = new Promise(function(resolve) {
|
|
179
|
+
return resolves[0] = resolve;
|
|
180
|
+
});
|
|
181
|
+
call1 = new Promise(function(resolve) {
|
|
182
|
+
return resolves[1] = resolve;
|
|
183
|
+
});
|
|
184
|
+
result = {
|
|
185
|
+
res: false
|
|
186
|
+
};
|
|
187
|
+
void plugin.load({}).transform(call0);
|
|
188
|
+
runner1 = plugin.load({});
|
|
189
|
+
canStart1 = runner1.canStart();
|
|
190
|
+
return [
|
|
191
|
+
4,
|
|
192
|
+
jest.runAllTimersAsync()
|
|
193
|
+
];
|
|
194
|
+
case 1:
|
|
195
|
+
_state.sent();
|
|
196
|
+
return [
|
|
197
|
+
4,
|
|
198
|
+
canStart1
|
|
199
|
+
];
|
|
200
|
+
case 2:
|
|
201
|
+
expect.apply(void 0, [
|
|
202
|
+
_state.sent()
|
|
203
|
+
]).toBe(true);
|
|
204
|
+
void runner1.transform(call1);
|
|
205
|
+
runner2 = plugin.load({});
|
|
206
|
+
pCanStart2 = runner2.canStart();
|
|
207
|
+
return [
|
|
208
|
+
4,
|
|
209
|
+
jest.runAllTimersAsync()
|
|
210
|
+
];
|
|
211
|
+
case 3:
|
|
212
|
+
_state.sent();
|
|
213
|
+
expect(plugin.waitingResolvers.length).toBe(1);
|
|
214
|
+
result.res = true;
|
|
215
|
+
resolves[0]();
|
|
216
|
+
return [
|
|
217
|
+
4,
|
|
218
|
+
pCanStart2
|
|
219
|
+
];
|
|
220
|
+
case 4:
|
|
221
|
+
expect.apply(void 0, [
|
|
222
|
+
_state.sent()
|
|
223
|
+
]).toBe(true);
|
|
224
|
+
resolves[1]();
|
|
225
|
+
return [
|
|
226
|
+
4,
|
|
227
|
+
jest.advanceTimersByTimeAsync(500)
|
|
228
|
+
];
|
|
229
|
+
case 5:
|
|
230
|
+
_state.sent();
|
|
231
|
+
expect(plugin.waitingResolvers.length).toBe(0);
|
|
232
|
+
return [
|
|
233
|
+
2
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
})();
|
|
238
|
+
});
|
|
235
239
|
});
|
|
@@ -221,7 +221,6 @@ var KeepaliveRequest = /*#__PURE__*/ function() {
|
|
|
221
221
|
* https://bugs.chromium.org/p/chromium/issues/detail?id=835821
|
|
222
222
|
* To avoid this issue we do a fake fetch call to check whether we can activate it or not in the browser.
|
|
223
223
|
*/ function testKeepAlive() {
|
|
224
|
-
var _this = this;
|
|
225
224
|
return _async_to_generator(function() {
|
|
226
225
|
var customHeaders, e;
|
|
227
226
|
return _ts_generator(this, function(_state) {
|
|
@@ -246,14 +245,14 @@ var KeepaliveRequest = /*#__PURE__*/ function() {
|
|
|
246
245
|
];
|
|
247
246
|
case 2:
|
|
248
247
|
_state.sent();
|
|
249
|
-
|
|
248
|
+
this.active = true;
|
|
250
249
|
return [
|
|
251
250
|
3,
|
|
252
251
|
4
|
|
253
252
|
];
|
|
254
253
|
case 3:
|
|
255
254
|
e = _state.sent();
|
|
256
|
-
|
|
255
|
+
this.active = false;
|
|
257
256
|
return [
|
|
258
257
|
3,
|
|
259
258
|
4
|
|
@@ -264,7 +263,7 @@ var KeepaliveRequest = /*#__PURE__*/ function() {
|
|
|
264
263
|
];
|
|
265
264
|
}
|
|
266
265
|
});
|
|
267
|
-
})();
|
|
266
|
+
}).call(this);
|
|
268
267
|
}
|
|
269
268
|
},
|
|
270
269
|
{
|
|
@@ -129,30 +129,32 @@ describe('Keepalive Request Plugin', function() {
|
|
|
129
129
|
basePath: 'http://test.com/truc',
|
|
130
130
|
method: 'get'
|
|
131
131
|
};
|
|
132
|
-
it('keepalive should be set to true',
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
132
|
+
it('keepalive should be set to true', function() {
|
|
133
|
+
return _async_to_generator(function() {
|
|
134
|
+
var plugin, runner, keepalive;
|
|
135
|
+
return _ts_generator(this, function(_state) {
|
|
136
|
+
switch(_state.label){
|
|
137
|
+
case 0:
|
|
138
|
+
plugin = new _keepaliverequest.KeepaliveRequest(true);
|
|
139
|
+
runner = plugin.load();
|
|
140
|
+
return [
|
|
141
|
+
4,
|
|
142
|
+
runner.transform(options)
|
|
143
|
+
];
|
|
144
|
+
case 1:
|
|
145
|
+
_state.sent();
|
|
146
|
+
return [
|
|
147
|
+
4,
|
|
148
|
+
plugin.load().transform(options)
|
|
149
|
+
];
|
|
150
|
+
case 2:
|
|
151
|
+
keepalive = _state.sent().keepalive;
|
|
152
|
+
expect(keepalive).toBe(true);
|
|
153
|
+
return [
|
|
154
|
+
2
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
})();
|
|
159
|
+
});
|
|
158
160
|
});
|