@merchi/cart 1.4.64 → 1.4.65
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/esm/CartProvider.js +42 -23
- package/esm/CartProvider.load.test.js +774 -387
- package/lib/CartProvider.js +41 -22
- package/package.json +1 -1
- package/src/CartProvider.load.test.tsx +103 -0
- package/src/CartProvider.tsx +23 -12
|
@@ -15,7 +15,7 @@ import CartProvider, { useCartContext } from './CartProvider';
|
|
|
15
15
|
import { getCartCookie, setCartCookie } from './utilities/cookie';
|
|
16
16
|
import { reportCartFailure, CART_FAILURE_SOURCES } from './utilities/reportFailure';
|
|
17
17
|
import { tabIdClearCart, tabIdItems } from './utilities/tabs';
|
|
18
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
19
|
var mockGet = jest.fn();
|
|
20
20
|
var mockPost = jest.fn();
|
|
21
21
|
var mockCreateItem = jest.fn();
|
|
@@ -124,6 +124,7 @@ function Probe() {
|
|
|
124
124
|
context = useCartContext();
|
|
125
125
|
return null;
|
|
126
126
|
}
|
|
127
|
+
var bindingNames = ['addCartItem', 'toggleCartOpen', 'getCart', 'getMerchiCartValues', 'isMerchiCartFetching', 'setCartComplete', 'refetchCart', 'createCartAndCookie'];
|
|
127
128
|
describe('cart load and replacement failures', function () {
|
|
128
129
|
var root;
|
|
129
130
|
var container;
|
|
@@ -136,6 +137,10 @@ describe('cart load and replacement failures', function () {
|
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
139
|
beforeEach(function () {
|
|
140
|
+
for (var _i = 0, _bindingNames = bindingNames; _i < _bindingNames.length; _i++) {
|
|
141
|
+
var name = _bindingNames[_i];
|
|
142
|
+
delete window[name];
|
|
143
|
+
}
|
|
139
144
|
jest.clearAllMocks();
|
|
140
145
|
mockGet.mockReset();
|
|
141
146
|
mockPost.mockReset();
|
|
@@ -191,15 +196,15 @@ describe('cart load and replacement failures', function () {
|
|
|
191
196
|
return _mount.apply(this, arguments);
|
|
192
197
|
}
|
|
193
198
|
function _mount() {
|
|
194
|
-
_mount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
195
|
-
return _regenerator().w(function (
|
|
196
|
-
while (1) switch (
|
|
199
|
+
_mount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(error) {
|
|
200
|
+
return _regenerator().w(function (_context81) {
|
|
201
|
+
while (1) switch (_context81.n) {
|
|
197
202
|
case 0:
|
|
198
203
|
mockGet.mockRejectedValue(error);
|
|
199
|
-
|
|
200
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
201
|
-
return _regenerator().w(function (
|
|
202
|
-
while (1) switch (
|
|
204
|
+
_context81.n = 1;
|
|
205
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80() {
|
|
206
|
+
return _regenerator().w(function (_context80) {
|
|
207
|
+
while (1) switch (_context80.n) {
|
|
203
208
|
case 0:
|
|
204
209
|
root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
205
210
|
domainId: 5,
|
|
@@ -213,14 +218,14 @@ describe('cart load and replacement failures', function () {
|
|
|
213
218
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
214
219
|
}));
|
|
215
220
|
case 1:
|
|
216
|
-
return
|
|
221
|
+
return _context80.a(2);
|
|
217
222
|
}
|
|
218
|
-
},
|
|
223
|
+
}, _callee80);
|
|
219
224
|
})));
|
|
220
225
|
case 1:
|
|
221
|
-
return
|
|
226
|
+
return _context81.a(2);
|
|
222
227
|
}
|
|
223
|
-
},
|
|
228
|
+
}, _callee81);
|
|
224
229
|
}));
|
|
225
230
|
return _mount.apply(this, arguments);
|
|
226
231
|
}
|
|
@@ -228,9 +233,9 @@ describe('cart load and replacement failures', function () {
|
|
|
228
233
|
return _mountSavedCart.apply(this, arguments);
|
|
229
234
|
}
|
|
230
235
|
function _mountSavedCart() {
|
|
231
|
-
_mountSavedCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
232
|
-
return _regenerator().w(function (
|
|
233
|
-
while (1) switch (
|
|
236
|
+
_mountSavedCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84() {
|
|
237
|
+
return _regenerator().w(function (_context84) {
|
|
238
|
+
while (1) switch (_context84.n) {
|
|
234
239
|
case 0:
|
|
235
240
|
mockGet.mockResolvedValue({
|
|
236
241
|
toJson: function toJson() {
|
|
@@ -243,10 +248,10 @@ describe('cart load and replacement failures', function () {
|
|
|
243
248
|
};
|
|
244
249
|
}
|
|
245
250
|
});
|
|
246
|
-
|
|
247
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
248
|
-
return _regenerator().w(function (
|
|
249
|
-
while (1) switch (
|
|
251
|
+
_context84.n = 1;
|
|
252
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82() {
|
|
253
|
+
return _regenerator().w(function (_context82) {
|
|
254
|
+
while (1) switch (_context82.n) {
|
|
250
255
|
case 0:
|
|
251
256
|
root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
252
257
|
domainId: 5,
|
|
@@ -254,46 +259,428 @@ describe('cart load and replacement failures', function () {
|
|
|
254
259
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
255
260
|
}));
|
|
256
261
|
case 1:
|
|
257
|
-
return
|
|
262
|
+
return _context82.a(2);
|
|
258
263
|
}
|
|
259
|
-
},
|
|
264
|
+
}, _callee82);
|
|
260
265
|
})));
|
|
261
266
|
case 1:
|
|
262
|
-
|
|
263
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
264
|
-
return _regenerator().w(function (
|
|
265
|
-
while (1) switch (
|
|
267
|
+
_context84.n = 2;
|
|
268
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83() {
|
|
269
|
+
return _regenerator().w(function (_context83) {
|
|
270
|
+
while (1) switch (_context83.n) {
|
|
266
271
|
case 0:
|
|
267
|
-
return
|
|
272
|
+
return _context83.a(2, context.setActiveTabIndex(tabIdClearCart));
|
|
268
273
|
}
|
|
269
|
-
},
|
|
274
|
+
}, _callee83);
|
|
270
275
|
})));
|
|
271
276
|
case 2:
|
|
272
|
-
return
|
|
277
|
+
return _context84.a(2);
|
|
273
278
|
}
|
|
274
|
-
},
|
|
279
|
+
}, _callee84);
|
|
275
280
|
}));
|
|
276
281
|
return _mountSavedCart.apply(this, arguments);
|
|
277
282
|
}
|
|
283
|
+
it('does not expose cart operations until a suspended provider commits', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
284
|
+
var ready, release, gate, Suspender, _i2, _bindingNames2, name, _i3, _bindingNames3, _name, _t;
|
|
285
|
+
return _regenerator().w(function (_context6) {
|
|
286
|
+
while (1) switch (_context6.n) {
|
|
287
|
+
case 0:
|
|
288
|
+
Suspender = function _Suspender() {
|
|
289
|
+
if (!ready) throw gate;
|
|
290
|
+
return null;
|
|
291
|
+
};
|
|
292
|
+
setUserAgent(headlessUserAgent);
|
|
293
|
+
getCartCookie.mockResolvedValue(undefined);
|
|
294
|
+
ready = false;
|
|
295
|
+
gate = new Promise(function (resolve) {
|
|
296
|
+
release = resolve;
|
|
297
|
+
});
|
|
298
|
+
_context6.n = 1;
|
|
299
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
300
|
+
return _regenerator().w(function (_context3) {
|
|
301
|
+
while (1) switch (_context3.n) {
|
|
302
|
+
case 0:
|
|
303
|
+
return _context3.a(2, root.render(/*#__PURE__*/_jsx(React.Suspense, {
|
|
304
|
+
fallback: /*#__PURE__*/_jsx("span", {
|
|
305
|
+
children: "Loading"
|
|
306
|
+
}),
|
|
307
|
+
children: /*#__PURE__*/_jsxs(CartProvider, {
|
|
308
|
+
domainId: 5,
|
|
309
|
+
createCartAndCookie: function createCartAndCookie() {},
|
|
310
|
+
children: [/*#__PURE__*/_jsx(Suspender, {}), /*#__PURE__*/_jsx(Probe, {})]
|
|
311
|
+
})
|
|
312
|
+
})));
|
|
313
|
+
}
|
|
314
|
+
}, _callee3);
|
|
315
|
+
})));
|
|
316
|
+
case 1:
|
|
317
|
+
for (_i2 = 0, _bindingNames2 = bindingNames; _i2 < _bindingNames2.length; _i2++) {
|
|
318
|
+
name = _bindingNames2[_i2];
|
|
319
|
+
expect(window[name]).toBeUndefined();
|
|
320
|
+
}
|
|
321
|
+
expect(mockPost).not.toHaveBeenCalled();
|
|
322
|
+
_context6.n = 2;
|
|
323
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
324
|
+
return _regenerator().w(function (_context4) {
|
|
325
|
+
while (1) switch (_context4.n) {
|
|
326
|
+
case 0:
|
|
327
|
+
ready = true;
|
|
328
|
+
release();
|
|
329
|
+
case 1:
|
|
330
|
+
return _context4.a(2);
|
|
331
|
+
}
|
|
332
|
+
}, _callee4);
|
|
333
|
+
})));
|
|
334
|
+
case 2:
|
|
335
|
+
for (_i3 = 0, _bindingNames3 = bindingNames; _i3 < _bindingNames3.length; _i3++) {
|
|
336
|
+
_name = _bindingNames3[_i3];
|
|
337
|
+
expect(window[_name]).toBeInstanceOf(Function);
|
|
338
|
+
}
|
|
339
|
+
_context6.n = 3;
|
|
340
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
341
|
+
return _regenerator().w(function (_context5) {
|
|
342
|
+
while (1) switch (_context5.n) {
|
|
343
|
+
case 0:
|
|
344
|
+
_context5.n = 1;
|
|
345
|
+
return window.getCart();
|
|
346
|
+
case 1:
|
|
347
|
+
return _context5.a(2);
|
|
348
|
+
}
|
|
349
|
+
}, _callee5);
|
|
350
|
+
})));
|
|
351
|
+
case 3:
|
|
352
|
+
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
353
|
+
_t = expect;
|
|
354
|
+
_context6.n = 4;
|
|
355
|
+
return window.getMerchiCartValues();
|
|
356
|
+
case 4:
|
|
357
|
+
_t(_context6.v.cart.id).toBe(99);
|
|
358
|
+
expect(context.cart.id).toBe(99);
|
|
359
|
+
case 5:
|
|
360
|
+
return _context6.a(2);
|
|
361
|
+
}
|
|
362
|
+
}, _callee6);
|
|
363
|
+
})));
|
|
364
|
+
it('preserves committed operations when another provider suspends and is abandoned', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
365
|
+
var committed, otherRoot, gate, Suspender, _t2;
|
|
366
|
+
return _regenerator().w(function (_context1) {
|
|
367
|
+
while (1) switch (_context1.p = _context1.n) {
|
|
368
|
+
case 0:
|
|
369
|
+
Suspender = function _Suspender2() {
|
|
370
|
+
throw gate;
|
|
371
|
+
};
|
|
372
|
+
setUserAgent(headlessUserAgent);
|
|
373
|
+
getCartCookie.mockResolvedValue(undefined);
|
|
374
|
+
_context1.n = 1;
|
|
375
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
376
|
+
return _regenerator().w(function (_context7) {
|
|
377
|
+
while (1) switch (_context7.n) {
|
|
378
|
+
case 0:
|
|
379
|
+
return _context7.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
380
|
+
domainId: 5,
|
|
381
|
+
createCartAndCookie: function createCartAndCookie() {},
|
|
382
|
+
children: /*#__PURE__*/_jsx(Probe, {})
|
|
383
|
+
})));
|
|
384
|
+
}
|
|
385
|
+
}, _callee7);
|
|
386
|
+
})));
|
|
387
|
+
case 1:
|
|
388
|
+
committed = bindingNames.map(function (name) {
|
|
389
|
+
return window[name];
|
|
390
|
+
});
|
|
391
|
+
otherRoot = createRoot(document.createElement('div'));
|
|
392
|
+
gate = new Promise(function () {});
|
|
393
|
+
_context1.p = 2;
|
|
394
|
+
_context1.n = 3;
|
|
395
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
396
|
+
return _regenerator().w(function (_context8) {
|
|
397
|
+
while (1) switch (_context8.n) {
|
|
398
|
+
case 0:
|
|
399
|
+
return _context8.a(2, otherRoot.render(/*#__PURE__*/_jsx(React.Suspense, {
|
|
400
|
+
fallback: null,
|
|
401
|
+
children: /*#__PURE__*/_jsx(CartProvider, {
|
|
402
|
+
domainId: 6,
|
|
403
|
+
createCartAndCookie: function createCartAndCookie() {},
|
|
404
|
+
children: /*#__PURE__*/_jsx(Suspender, {})
|
|
405
|
+
})
|
|
406
|
+
})));
|
|
407
|
+
}
|
|
408
|
+
}, _callee8);
|
|
409
|
+
})));
|
|
410
|
+
case 3:
|
|
411
|
+
bindingNames.forEach(function (name, index) {
|
|
412
|
+
return expect(window[name]).toBe(committed[index]);
|
|
413
|
+
});
|
|
414
|
+
_context1.n = 4;
|
|
415
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
416
|
+
return _regenerator().w(function (_context9) {
|
|
417
|
+
while (1) switch (_context9.n) {
|
|
418
|
+
case 0:
|
|
419
|
+
_context9.n = 1;
|
|
420
|
+
return window.getCart();
|
|
421
|
+
case 1:
|
|
422
|
+
return _context9.a(2);
|
|
423
|
+
}
|
|
424
|
+
}, _callee9);
|
|
425
|
+
})));
|
|
426
|
+
case 4:
|
|
427
|
+
expect(context.cart.id).toBe(99);
|
|
428
|
+
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
429
|
+
case 5:
|
|
430
|
+
_context1.p = 5;
|
|
431
|
+
_context1.n = 6;
|
|
432
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
433
|
+
return _regenerator().w(function (_context0) {
|
|
434
|
+
while (1) switch (_context0.n) {
|
|
435
|
+
case 0:
|
|
436
|
+
return _context0.a(2, otherRoot.unmount());
|
|
437
|
+
}
|
|
438
|
+
}, _callee0);
|
|
439
|
+
})));
|
|
440
|
+
case 6:
|
|
441
|
+
return _context1.f(5);
|
|
442
|
+
case 7:
|
|
443
|
+
_t2 = expect;
|
|
444
|
+
_context1.n = 8;
|
|
445
|
+
return window.getMerchiCartValues();
|
|
446
|
+
case 8:
|
|
447
|
+
_t2(_context1.v.cart.id).toBe(99);
|
|
448
|
+
case 9:
|
|
449
|
+
return _context1.a(2);
|
|
450
|
+
}
|
|
451
|
+
}, _callee1, null, [[2,, 5, 7]]);
|
|
452
|
+
})));
|
|
453
|
+
it('removes its own global operations on unmount', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
454
|
+
var _i4, _bindingNames4, name;
|
|
455
|
+
return _regenerator().w(function (_context11) {
|
|
456
|
+
while (1) switch (_context11.n) {
|
|
457
|
+
case 0:
|
|
458
|
+
_context11.n = 1;
|
|
459
|
+
return mountSavedCart();
|
|
460
|
+
case 1:
|
|
461
|
+
_context11.n = 2;
|
|
462
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
463
|
+
return _regenerator().w(function (_context10) {
|
|
464
|
+
while (1) switch (_context10.n) {
|
|
465
|
+
case 0:
|
|
466
|
+
return _context10.a(2, root.render(null));
|
|
467
|
+
}
|
|
468
|
+
}, _callee10);
|
|
469
|
+
})));
|
|
470
|
+
case 2:
|
|
471
|
+
for (_i4 = 0, _bindingNames4 = bindingNames; _i4 < _bindingNames4.length; _i4++) {
|
|
472
|
+
name = _bindingNames4[_i4];
|
|
473
|
+
expect(window[name]).toBeUndefined();
|
|
474
|
+
}
|
|
475
|
+
case 3:
|
|
476
|
+
return _context11.a(2);
|
|
477
|
+
}
|
|
478
|
+
}, _callee11);
|
|
479
|
+
})));
|
|
480
|
+
it('keeps the committed domain bindings during a suspended transition', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
481
|
+
var gate, Suspender, tree, committed, _t3;
|
|
482
|
+
return _regenerator().w(function (_context14) {
|
|
483
|
+
while (1) switch (_context14.n) {
|
|
484
|
+
case 0:
|
|
485
|
+
Suspender = function _Suspender3() {
|
|
486
|
+
throw gate;
|
|
487
|
+
};
|
|
488
|
+
setUserAgent(headlessUserAgent);
|
|
489
|
+
mockGet.mockResolvedValue({
|
|
490
|
+
toJson: function toJson() {
|
|
491
|
+
return {
|
|
492
|
+
id: 42,
|
|
493
|
+
cartItems: []
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
gate = new Promise(function () {});
|
|
498
|
+
tree = function tree(domainId, suspend) {
|
|
499
|
+
return /*#__PURE__*/_jsx(React.Suspense, {
|
|
500
|
+
fallback: null,
|
|
501
|
+
children: /*#__PURE__*/_jsx(CartProvider, {
|
|
502
|
+
domainId: domainId,
|
|
503
|
+
createCartAndCookie: function createCartAndCookie() {},
|
|
504
|
+
children: suspend ? /*#__PURE__*/_jsx(Suspender, {}) : /*#__PURE__*/_jsx(Probe, {})
|
|
505
|
+
})
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
_context14.n = 1;
|
|
509
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
510
|
+
return _regenerator().w(function (_context12) {
|
|
511
|
+
while (1) switch (_context12.n) {
|
|
512
|
+
case 0:
|
|
513
|
+
return _context12.a(2, root.render(tree(5, false)));
|
|
514
|
+
}
|
|
515
|
+
}, _callee12);
|
|
516
|
+
})));
|
|
517
|
+
case 1:
|
|
518
|
+
committed = bindingNames.map(function (name) {
|
|
519
|
+
return window[name];
|
|
520
|
+
});
|
|
521
|
+
_context14.n = 2;
|
|
522
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
523
|
+
return _regenerator().w(function (_context13) {
|
|
524
|
+
while (1) switch (_context13.n) {
|
|
525
|
+
case 0:
|
|
526
|
+
React.startTransition(function () {
|
|
527
|
+
return root.render(tree(6, true));
|
|
528
|
+
});
|
|
529
|
+
case 1:
|
|
530
|
+
return _context13.a(2);
|
|
531
|
+
}
|
|
532
|
+
}, _callee13);
|
|
533
|
+
})));
|
|
534
|
+
case 2:
|
|
535
|
+
bindingNames.forEach(function (name, index) {
|
|
536
|
+
return expect(window[name]).toBe(committed[index]);
|
|
537
|
+
});
|
|
538
|
+
_t3 = expect;
|
|
539
|
+
_context14.n = 3;
|
|
540
|
+
return window.getMerchiCartValues();
|
|
541
|
+
case 3:
|
|
542
|
+
_t3(_context14.v.cart.id).toBe(42);
|
|
543
|
+
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
544
|
+
expect(mockPost).not.toHaveBeenCalled();
|
|
545
|
+
case 4:
|
|
546
|
+
return _context14.a(2);
|
|
547
|
+
}
|
|
548
|
+
}, _callee14);
|
|
549
|
+
})));
|
|
550
|
+
it('does not remove global operations owned by another committed provider', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
|
|
551
|
+
var otherRoot, otherBindings, _i5, _bindingNames5, name, _t4;
|
|
552
|
+
return _regenerator().w(function (_context18) {
|
|
553
|
+
while (1) switch (_context18.p = _context18.n) {
|
|
554
|
+
case 0:
|
|
555
|
+
_context18.n = 1;
|
|
556
|
+
return mountSavedCart();
|
|
557
|
+
case 1:
|
|
558
|
+
otherRoot = createRoot(document.createElement('div'));
|
|
559
|
+
_context18.p = 2;
|
|
560
|
+
_context18.n = 3;
|
|
561
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
562
|
+
return _regenerator().w(function (_context15) {
|
|
563
|
+
while (1) switch (_context15.n) {
|
|
564
|
+
case 0:
|
|
565
|
+
return _context15.a(2, otherRoot.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
566
|
+
domainId: 6,
|
|
567
|
+
createCartAndCookie: function createCartAndCookie() {},
|
|
568
|
+
children: /*#__PURE__*/_jsx(Probe, {})
|
|
569
|
+
})));
|
|
570
|
+
}
|
|
571
|
+
}, _callee15);
|
|
572
|
+
})));
|
|
573
|
+
case 3:
|
|
574
|
+
otherBindings = bindingNames.map(function (name) {
|
|
575
|
+
return window[name];
|
|
576
|
+
});
|
|
577
|
+
_context18.n = 4;
|
|
578
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
579
|
+
return _regenerator().w(function (_context16) {
|
|
580
|
+
while (1) switch (_context16.n) {
|
|
581
|
+
case 0:
|
|
582
|
+
return _context16.a(2, root.render(null));
|
|
583
|
+
}
|
|
584
|
+
}, _callee16);
|
|
585
|
+
})));
|
|
586
|
+
case 4:
|
|
587
|
+
bindingNames.forEach(function (name, index) {
|
|
588
|
+
return expect(window[name]).toBe(otherBindings[index]);
|
|
589
|
+
});
|
|
590
|
+
_t4 = expect;
|
|
591
|
+
_context18.n = 5;
|
|
592
|
+
return window.getMerchiCartValues();
|
|
593
|
+
case 5:
|
|
594
|
+
_t4(_context18.v.cart.id).toBe(42);
|
|
595
|
+
case 6:
|
|
596
|
+
_context18.p = 6;
|
|
597
|
+
_context18.n = 7;
|
|
598
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
599
|
+
return _regenerator().w(function (_context17) {
|
|
600
|
+
while (1) switch (_context17.n) {
|
|
601
|
+
case 0:
|
|
602
|
+
return _context17.a(2, otherRoot.unmount());
|
|
603
|
+
}
|
|
604
|
+
}, _callee17);
|
|
605
|
+
})));
|
|
606
|
+
case 7:
|
|
607
|
+
return _context18.f(6);
|
|
608
|
+
case 8:
|
|
609
|
+
for (_i5 = 0, _bindingNames5 = bindingNames; _i5 < _bindingNames5.length; _i5++) {
|
|
610
|
+
name = _bindingNames5[_i5];
|
|
611
|
+
expect(window[name]).toBeUndefined();
|
|
612
|
+
}
|
|
613
|
+
case 9:
|
|
614
|
+
return _context18.a(2);
|
|
615
|
+
}
|
|
616
|
+
}, _callee18, null, [[2,, 6, 8]]);
|
|
617
|
+
})));
|
|
618
|
+
it('keeps globals usable after StrictMode setup and cleanup replay', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
|
|
619
|
+
var _t5;
|
|
620
|
+
return _regenerator().w(function (_context21) {
|
|
621
|
+
while (1) switch (_context21.n) {
|
|
622
|
+
case 0:
|
|
623
|
+
setUserAgent(headlessUserAgent);
|
|
624
|
+
getCartCookie.mockResolvedValue(undefined);
|
|
625
|
+
_context21.n = 1;
|
|
626
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
|
|
627
|
+
return _regenerator().w(function (_context19) {
|
|
628
|
+
while (1) switch (_context19.n) {
|
|
629
|
+
case 0:
|
|
630
|
+
return _context19.a(2, root.render(/*#__PURE__*/_jsx(React.StrictMode, {
|
|
631
|
+
children: /*#__PURE__*/_jsx(CartProvider, {
|
|
632
|
+
domainId: 5,
|
|
633
|
+
createCartAndCookie: function createCartAndCookie() {},
|
|
634
|
+
children: /*#__PURE__*/_jsx(Probe, {})
|
|
635
|
+
})
|
|
636
|
+
})));
|
|
637
|
+
}
|
|
638
|
+
}, _callee19);
|
|
639
|
+
})));
|
|
640
|
+
case 1:
|
|
641
|
+
_context21.n = 2;
|
|
642
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
|
|
643
|
+
return _regenerator().w(function (_context20) {
|
|
644
|
+
while (1) switch (_context20.n) {
|
|
645
|
+
case 0:
|
|
646
|
+
_context20.n = 1;
|
|
647
|
+
return window.getCart();
|
|
648
|
+
case 1:
|
|
649
|
+
return _context20.a(2);
|
|
650
|
+
}
|
|
651
|
+
}, _callee20);
|
|
652
|
+
})));
|
|
653
|
+
case 2:
|
|
654
|
+
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
655
|
+
_t5 = expect;
|
|
656
|
+
_context21.n = 3;
|
|
657
|
+
return window.getMerchiCartValues();
|
|
658
|
+
case 3:
|
|
659
|
+
_t5(_context21.v.cart.id).toBe(99);
|
|
660
|
+
case 4:
|
|
661
|
+
return _context21.a(2);
|
|
662
|
+
}
|
|
663
|
+
}, _callee21);
|
|
664
|
+
})));
|
|
278
665
|
it.each(['Mozilla/5.0 (X11; Linux x86_64) HeadlessChrome/153.0.8010.0 Safari/537.36', 'Mozilla/5.0 (compatible; Baiduspider-render/2.0)'])('does not create an unused cart on automated startup: %s', /*#__PURE__*/function () {
|
|
279
|
-
var
|
|
280
|
-
return _regenerator().w(function (
|
|
281
|
-
while (1) switch (
|
|
666
|
+
var _ref22 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(userAgent) {
|
|
667
|
+
return _regenerator().w(function (_context23) {
|
|
668
|
+
while (1) switch (_context23.n) {
|
|
282
669
|
case 0:
|
|
283
670
|
setUserAgent(userAgent);
|
|
284
671
|
getCartCookie.mockResolvedValue(undefined);
|
|
285
|
-
|
|
286
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
287
|
-
return _regenerator().w(function (
|
|
288
|
-
while (1) switch (
|
|
672
|
+
_context23.n = 1;
|
|
673
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22() {
|
|
674
|
+
return _regenerator().w(function (_context22) {
|
|
675
|
+
while (1) switch (_context22.n) {
|
|
289
676
|
case 0:
|
|
290
|
-
return
|
|
677
|
+
return _context22.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
291
678
|
domainId: 5,
|
|
292
679
|
createCartAndCookie: function createCartAndCookie() {},
|
|
293
680
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
294
681
|
})));
|
|
295
682
|
}
|
|
296
|
-
},
|
|
683
|
+
}, _callee22);
|
|
297
684
|
})));
|
|
298
685
|
case 1:
|
|
299
686
|
expect(mockGet).not.toHaveBeenCalled();
|
|
@@ -301,60 +688,60 @@ describe('cart load and replacement failures', function () {
|
|
|
301
688
|
expect(context.fetchingCart).toBe(false);
|
|
302
689
|
expect(reportCartFailure).not.toHaveBeenCalled();
|
|
303
690
|
case 2:
|
|
304
|
-
return
|
|
691
|
+
return _context23.a(2);
|
|
305
692
|
}
|
|
306
|
-
},
|
|
693
|
+
}, _callee23);
|
|
307
694
|
}));
|
|
308
695
|
return function (_x2) {
|
|
309
|
-
return
|
|
696
|
+
return _ref22.apply(this, arguments);
|
|
310
697
|
};
|
|
311
698
|
}());
|
|
312
|
-
it('allows explicit cart opening and concurrent callers in an automated browser', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
313
|
-
return _regenerator().w(function (
|
|
314
|
-
while (1) switch (
|
|
699
|
+
it('allows explicit cart opening and concurrent callers in an automated browser', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26() {
|
|
700
|
+
return _regenerator().w(function (_context26) {
|
|
701
|
+
while (1) switch (_context26.n) {
|
|
315
702
|
case 0:
|
|
316
703
|
setUserAgent(headlessUserAgent);
|
|
317
704
|
getCartCookie.mockResolvedValue(undefined);
|
|
318
|
-
|
|
319
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
320
|
-
return _regenerator().w(function (
|
|
321
|
-
while (1) switch (
|
|
705
|
+
_context26.n = 1;
|
|
706
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24() {
|
|
707
|
+
return _regenerator().w(function (_context24) {
|
|
708
|
+
while (1) switch (_context24.n) {
|
|
322
709
|
case 0:
|
|
323
|
-
return
|
|
710
|
+
return _context24.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
324
711
|
domainId: 5,
|
|
325
712
|
createCartAndCookie: function createCartAndCookie() {},
|
|
326
713
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
327
714
|
})));
|
|
328
715
|
}
|
|
329
|
-
},
|
|
716
|
+
}, _callee24);
|
|
330
717
|
})));
|
|
331
718
|
case 1:
|
|
332
719
|
expect(mockPost).not.toHaveBeenCalled();
|
|
333
|
-
|
|
334
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
335
|
-
return _regenerator().w(function (
|
|
336
|
-
while (1) switch (
|
|
720
|
+
_context26.n = 2;
|
|
721
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25() {
|
|
722
|
+
return _regenerator().w(function (_context25) {
|
|
723
|
+
while (1) switch (_context25.n) {
|
|
337
724
|
case 0:
|
|
338
725
|
context.toggleCartModal();
|
|
339
|
-
|
|
726
|
+
_context25.n = 1;
|
|
340
727
|
return Promise.all([window.getCart(), window.refetchCart()]);
|
|
341
728
|
case 1:
|
|
342
|
-
return
|
|
729
|
+
return _context25.a(2);
|
|
343
730
|
}
|
|
344
|
-
},
|
|
731
|
+
}, _callee25);
|
|
345
732
|
})));
|
|
346
733
|
case 2:
|
|
347
734
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
348
735
|
expect(context.cart.id).toBe(99);
|
|
349
736
|
case 3:
|
|
350
|
-
return
|
|
737
|
+
return _context26.a(2);
|
|
351
738
|
}
|
|
352
|
-
},
|
|
739
|
+
}, _callee26);
|
|
353
740
|
})));
|
|
354
|
-
it('creates once when explicit interaction joins a pending passive cookie lookup', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
741
|
+
it('creates once when explicit interaction joins a pending passive cookie lookup', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee30() {
|
|
355
742
|
var finishCookie, first, second;
|
|
356
|
-
return _regenerator().w(function (
|
|
357
|
-
while (1) switch (
|
|
743
|
+
return _regenerator().w(function (_context30) {
|
|
744
|
+
while (1) switch (_context30.n) {
|
|
358
745
|
case 0:
|
|
359
746
|
setUserAgent(headlessUserAgent);
|
|
360
747
|
getCartCookie.mockImplementationOnce(function () {
|
|
@@ -362,60 +749,60 @@ describe('cart load and replacement failures', function () {
|
|
|
362
749
|
finishCookie = resolve;
|
|
363
750
|
});
|
|
364
751
|
}).mockResolvedValue(undefined);
|
|
365
|
-
|
|
366
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
367
|
-
return _regenerator().w(function (
|
|
368
|
-
while (1) switch (
|
|
752
|
+
_context30.n = 1;
|
|
753
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27() {
|
|
754
|
+
return _regenerator().w(function (_context27) {
|
|
755
|
+
while (1) switch (_context27.n) {
|
|
369
756
|
case 0:
|
|
370
|
-
return
|
|
757
|
+
return _context27.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
371
758
|
domainId: 5,
|
|
372
759
|
createCartAndCookie: function createCartAndCookie() {},
|
|
373
760
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
374
761
|
})));
|
|
375
762
|
}
|
|
376
|
-
},
|
|
763
|
+
}, _callee27);
|
|
377
764
|
})));
|
|
378
765
|
case 1:
|
|
379
|
-
|
|
380
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
381
|
-
return _regenerator().w(function (
|
|
382
|
-
while (1) switch (
|
|
766
|
+
_context30.n = 2;
|
|
767
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28() {
|
|
768
|
+
return _regenerator().w(function (_context28) {
|
|
769
|
+
while (1) switch (_context28.n) {
|
|
383
770
|
case 0:
|
|
384
771
|
first = window.getCart();
|
|
385
772
|
second = window.getCart();
|
|
386
773
|
context.toggleCartModal();
|
|
387
774
|
case 1:
|
|
388
|
-
return
|
|
775
|
+
return _context28.a(2);
|
|
389
776
|
}
|
|
390
|
-
},
|
|
777
|
+
}, _callee28);
|
|
391
778
|
})));
|
|
392
779
|
case 2:
|
|
393
780
|
expect(mockPost).not.toHaveBeenCalled();
|
|
394
|
-
|
|
395
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
396
|
-
return _regenerator().w(function (
|
|
397
|
-
while (1) switch (
|
|
781
|
+
_context30.n = 3;
|
|
782
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29() {
|
|
783
|
+
return _regenerator().w(function (_context29) {
|
|
784
|
+
while (1) switch (_context29.n) {
|
|
398
785
|
case 0:
|
|
399
786
|
finishCookie(undefined);
|
|
400
|
-
|
|
787
|
+
_context29.n = 1;
|
|
401
788
|
return Promise.all([first, second]);
|
|
402
789
|
case 1:
|
|
403
|
-
return
|
|
790
|
+
return _context29.a(2);
|
|
404
791
|
}
|
|
405
|
-
},
|
|
792
|
+
}, _callee29);
|
|
406
793
|
})));
|
|
407
794
|
case 3:
|
|
408
795
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
409
796
|
expect(context.cart.id).toBe(99);
|
|
410
797
|
case 4:
|
|
411
|
-
return
|
|
798
|
+
return _context30.a(2);
|
|
412
799
|
}
|
|
413
|
-
},
|
|
800
|
+
}, _callee30);
|
|
414
801
|
})));
|
|
415
|
-
it('restores saved carts for automated clients without duplicating an active read', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
802
|
+
it('restores saved carts for automated clients without duplicating an active read', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee34() {
|
|
416
803
|
var finish, read;
|
|
417
|
-
return _regenerator().w(function (
|
|
418
|
-
while (1) switch (
|
|
804
|
+
return _regenerator().w(function (_context34) {
|
|
805
|
+
while (1) switch (_context34.n) {
|
|
419
806
|
case 0:
|
|
420
807
|
setUserAgent(headlessUserAgent);
|
|
421
808
|
mockGet.mockImplementationOnce(function () {
|
|
@@ -423,38 +810,38 @@ describe('cart load and replacement failures', function () {
|
|
|
423
810
|
finish = resolve;
|
|
424
811
|
});
|
|
425
812
|
});
|
|
426
|
-
|
|
427
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
428
|
-
return _regenerator().w(function (
|
|
429
|
-
while (1) switch (
|
|
813
|
+
_context34.n = 1;
|
|
814
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee31() {
|
|
815
|
+
return _regenerator().w(function (_context31) {
|
|
816
|
+
while (1) switch (_context31.n) {
|
|
430
817
|
case 0:
|
|
431
|
-
return
|
|
818
|
+
return _context31.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
432
819
|
domainId: 5,
|
|
433
820
|
createCartAndCookie: function createCartAndCookie() {},
|
|
434
821
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
435
822
|
})));
|
|
436
823
|
}
|
|
437
|
-
},
|
|
824
|
+
}, _callee31);
|
|
438
825
|
})));
|
|
439
826
|
case 1:
|
|
440
|
-
|
|
441
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
442
|
-
return _regenerator().w(function (
|
|
443
|
-
while (1) switch (
|
|
827
|
+
_context34.n = 2;
|
|
828
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee32() {
|
|
829
|
+
return _regenerator().w(function (_context32) {
|
|
830
|
+
while (1) switch (_context32.n) {
|
|
444
831
|
case 0:
|
|
445
832
|
read = window.getCart();
|
|
446
833
|
context.toggleCartModal();
|
|
447
834
|
case 1:
|
|
448
|
-
return
|
|
835
|
+
return _context32.a(2);
|
|
449
836
|
}
|
|
450
|
-
},
|
|
837
|
+
}, _callee32);
|
|
451
838
|
})));
|
|
452
839
|
case 2:
|
|
453
840
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
454
|
-
|
|
455
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
456
|
-
return _regenerator().w(function (
|
|
457
|
-
while (1) switch (
|
|
841
|
+
_context34.n = 3;
|
|
842
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee33() {
|
|
843
|
+
return _regenerator().w(function (_context33) {
|
|
844
|
+
while (1) switch (_context33.n) {
|
|
458
845
|
case 0:
|
|
459
846
|
finish({
|
|
460
847
|
toJson: function toJson() {
|
|
@@ -467,106 +854,106 @@ describe('cart load and replacement failures', function () {
|
|
|
467
854
|
};
|
|
468
855
|
}
|
|
469
856
|
});
|
|
470
|
-
|
|
857
|
+
_context33.n = 1;
|
|
471
858
|
return read;
|
|
472
859
|
case 1:
|
|
473
|
-
return
|
|
860
|
+
return _context33.a(2);
|
|
474
861
|
}
|
|
475
|
-
},
|
|
862
|
+
}, _callee33);
|
|
476
863
|
})));
|
|
477
864
|
case 3:
|
|
478
865
|
expect(mockPost).not.toHaveBeenCalled();
|
|
479
866
|
expect(context.cart.cartItems).toHaveLength(1);
|
|
480
867
|
case 4:
|
|
481
|
-
return
|
|
868
|
+
return _context34.a(2);
|
|
482
869
|
}
|
|
483
|
-
},
|
|
870
|
+
}, _callee34);
|
|
484
871
|
})));
|
|
485
|
-
it('keeps explicit retry available after an automated client creation fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
486
|
-
return _regenerator().w(function (
|
|
487
|
-
while (1) switch (
|
|
872
|
+
it('keeps explicit retry available after an automated client creation fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee38() {
|
|
873
|
+
return _regenerator().w(function (_context38) {
|
|
874
|
+
while (1) switch (_context38.n) {
|
|
488
875
|
case 0:
|
|
489
876
|
setUserAgent(headlessUserAgent);
|
|
490
877
|
getCartCookie.mockResolvedValue(undefined);
|
|
491
878
|
mockPost.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
492
|
-
|
|
493
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
494
|
-
return _regenerator().w(function (
|
|
495
|
-
while (1) switch (
|
|
879
|
+
_context38.n = 1;
|
|
880
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee35() {
|
|
881
|
+
return _regenerator().w(function (_context35) {
|
|
882
|
+
while (1) switch (_context35.n) {
|
|
496
883
|
case 0:
|
|
497
|
-
return
|
|
884
|
+
return _context35.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
498
885
|
domainId: 5,
|
|
499
886
|
createCartAndCookie: function createCartAndCookie() {},
|
|
500
887
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
501
888
|
})));
|
|
502
889
|
}
|
|
503
|
-
},
|
|
890
|
+
}, _callee35);
|
|
504
891
|
})));
|
|
505
892
|
case 1:
|
|
506
893
|
expect(mockPost).not.toHaveBeenCalled();
|
|
507
|
-
|
|
508
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
509
|
-
return _regenerator().w(function (
|
|
510
|
-
while (1) switch (
|
|
894
|
+
_context38.n = 2;
|
|
895
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee36() {
|
|
896
|
+
return _regenerator().w(function (_context36) {
|
|
897
|
+
while (1) switch (_context36.n) {
|
|
511
898
|
case 0:
|
|
512
|
-
|
|
899
|
+
_context36.n = 1;
|
|
513
900
|
return window.getCart();
|
|
514
901
|
case 1:
|
|
515
|
-
return
|
|
902
|
+
return _context36.a(2);
|
|
516
903
|
}
|
|
517
|
-
},
|
|
904
|
+
}, _callee36);
|
|
518
905
|
})));
|
|
519
906
|
case 2:
|
|
520
907
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
521
908
|
expect(context.fetchingCart).toBe(false);
|
|
522
|
-
|
|
523
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
524
|
-
return _regenerator().w(function (
|
|
525
|
-
while (1) switch (
|
|
909
|
+
_context38.n = 3;
|
|
910
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee37() {
|
|
911
|
+
return _regenerator().w(function (_context37) {
|
|
912
|
+
while (1) switch (_context37.n) {
|
|
526
913
|
case 0:
|
|
527
|
-
|
|
914
|
+
_context37.n = 1;
|
|
528
915
|
return window.getCart();
|
|
529
916
|
case 1:
|
|
530
|
-
return
|
|
917
|
+
return _context37.a(2);
|
|
531
918
|
}
|
|
532
|
-
},
|
|
919
|
+
}, _callee37);
|
|
533
920
|
})));
|
|
534
921
|
case 3:
|
|
535
922
|
expect(mockPost).toHaveBeenCalledTimes(2);
|
|
536
923
|
expect(context.cart.id).toBe(99);
|
|
537
924
|
case 4:
|
|
538
|
-
return
|
|
925
|
+
return _context38.a(2);
|
|
539
926
|
}
|
|
540
|
-
},
|
|
927
|
+
}, _callee38);
|
|
541
928
|
})));
|
|
542
|
-
it('initializes a cart for a direct item operation without a storefront readiness helper', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
929
|
+
it('initializes a cart for a direct item operation without a storefront readiness helper', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee41() {
|
|
543
930
|
var onSuccess, onError;
|
|
544
|
-
return _regenerator().w(function (
|
|
545
|
-
while (1) switch (
|
|
931
|
+
return _regenerator().w(function (_context41) {
|
|
932
|
+
while (1) switch (_context41.n) {
|
|
546
933
|
case 0:
|
|
547
934
|
setUserAgent(headlessUserAgent);
|
|
548
935
|
getCartCookie.mockResolvedValue(undefined);
|
|
549
|
-
|
|
550
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
551
|
-
return _regenerator().w(function (
|
|
552
|
-
while (1) switch (
|
|
936
|
+
_context41.n = 1;
|
|
937
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee39() {
|
|
938
|
+
return _regenerator().w(function (_context39) {
|
|
939
|
+
while (1) switch (_context39.n) {
|
|
553
940
|
case 0:
|
|
554
|
-
return
|
|
941
|
+
return _context39.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
555
942
|
domainId: 5,
|
|
556
943
|
createCartAndCookie: function createCartAndCookie() {},
|
|
557
944
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
558
945
|
})));
|
|
559
946
|
}
|
|
560
|
-
},
|
|
947
|
+
}, _callee39);
|
|
561
948
|
})));
|
|
562
949
|
case 1:
|
|
563
950
|
onSuccess = jest.fn(), onError = jest.fn();
|
|
564
|
-
|
|
565
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
566
|
-
return _regenerator().w(function (
|
|
567
|
-
while (1) switch (
|
|
951
|
+
_context41.n = 2;
|
|
952
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee40() {
|
|
953
|
+
return _regenerator().w(function (_context40) {
|
|
954
|
+
while (1) switch (_context40.n) {
|
|
568
955
|
case 0:
|
|
569
|
-
|
|
956
|
+
_context40.n = 1;
|
|
570
957
|
return window.addCartItem({
|
|
571
958
|
product: {
|
|
572
959
|
id: 44
|
|
@@ -574,9 +961,9 @@ describe('cart load and replacement failures', function () {
|
|
|
574
961
|
quantity: 100
|
|
575
962
|
}, onSuccess, onError);
|
|
576
963
|
case 1:
|
|
577
|
-
return
|
|
964
|
+
return _context40.a(2);
|
|
578
965
|
}
|
|
579
|
-
},
|
|
966
|
+
}, _callee40);
|
|
580
967
|
})));
|
|
581
968
|
case 2:
|
|
582
969
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
@@ -589,39 +976,39 @@ describe('cart load and replacement failures', function () {
|
|
|
589
976
|
});
|
|
590
977
|
expect(onError).not.toHaveBeenCalled();
|
|
591
978
|
case 3:
|
|
592
|
-
return
|
|
979
|
+
return _context41.a(2);
|
|
593
980
|
}
|
|
594
|
-
},
|
|
981
|
+
}, _callee41);
|
|
595
982
|
})));
|
|
596
|
-
it('rejects a direct item operation when initialization fails without posting an item', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
983
|
+
it('rejects a direct item operation when initialization fails without posting an item', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee44() {
|
|
597
984
|
var onSuccess, onError;
|
|
598
|
-
return _regenerator().w(function (
|
|
599
|
-
while (1) switch (
|
|
985
|
+
return _regenerator().w(function (_context44) {
|
|
986
|
+
while (1) switch (_context44.n) {
|
|
600
987
|
case 0:
|
|
601
988
|
setUserAgent(headlessUserAgent);
|
|
602
989
|
getCartCookie.mockResolvedValue(undefined);
|
|
603
990
|
mockPost.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
604
|
-
|
|
605
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
606
|
-
return _regenerator().w(function (
|
|
607
|
-
while (1) switch (
|
|
991
|
+
_context44.n = 1;
|
|
992
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee42() {
|
|
993
|
+
return _regenerator().w(function (_context42) {
|
|
994
|
+
while (1) switch (_context42.n) {
|
|
608
995
|
case 0:
|
|
609
|
-
return
|
|
996
|
+
return _context42.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
610
997
|
domainId: 5,
|
|
611
998
|
createCartAndCookie: function createCartAndCookie() {},
|
|
612
999
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
613
1000
|
})));
|
|
614
1001
|
}
|
|
615
|
-
},
|
|
1002
|
+
}, _callee42);
|
|
616
1003
|
})));
|
|
617
1004
|
case 1:
|
|
618
1005
|
onSuccess = jest.fn(), onError = jest.fn();
|
|
619
|
-
|
|
620
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
621
|
-
return _regenerator().w(function (
|
|
622
|
-
while (1) switch (
|
|
1006
|
+
_context44.n = 2;
|
|
1007
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee43() {
|
|
1008
|
+
return _regenerator().w(function (_context43) {
|
|
1009
|
+
while (1) switch (_context43.n) {
|
|
623
1010
|
case 0:
|
|
624
|
-
|
|
1011
|
+
_context43.n = 1;
|
|
625
1012
|
return window.addCartItem({
|
|
626
1013
|
product: {
|
|
627
1014
|
id: 44
|
|
@@ -629,9 +1016,9 @@ describe('cart load and replacement failures', function () {
|
|
|
629
1016
|
quantity: 100
|
|
630
1017
|
}, onSuccess, onError);
|
|
631
1018
|
case 1:
|
|
632
|
-
return
|
|
1019
|
+
return _context43.a(2);
|
|
633
1020
|
}
|
|
634
|
-
},
|
|
1021
|
+
}, _callee43);
|
|
635
1022
|
})));
|
|
636
1023
|
case 2:
|
|
637
1024
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
@@ -640,14 +1027,14 @@ describe('cart load and replacement failures', function () {
|
|
|
640
1027
|
expect(onError).toHaveBeenCalledTimes(1);
|
|
641
1028
|
expect(context.fetchingCart).toBe(false);
|
|
642
1029
|
case 3:
|
|
643
|
-
return
|
|
1030
|
+
return _context44.a(2);
|
|
644
1031
|
}
|
|
645
|
-
},
|
|
1032
|
+
}, _callee44);
|
|
646
1033
|
})));
|
|
647
|
-
it('waits for ordinary startup before concurrent direct item operations', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1034
|
+
it('waits for ordinary startup before concurrent direct item operations', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee48() {
|
|
648
1035
|
var finish, onSuccess, onError, first, second;
|
|
649
|
-
return _regenerator().w(function (
|
|
650
|
-
while (1) switch (
|
|
1036
|
+
return _regenerator().w(function (_context48) {
|
|
1037
|
+
while (1) switch (_context48.n) {
|
|
651
1038
|
case 0:
|
|
652
1039
|
getCartCookie.mockResolvedValue(undefined);
|
|
653
1040
|
mockPost.mockImplementationOnce(function () {
|
|
@@ -655,26 +1042,26 @@ describe('cart load and replacement failures', function () {
|
|
|
655
1042
|
finish = resolve;
|
|
656
1043
|
});
|
|
657
1044
|
});
|
|
658
|
-
|
|
659
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
660
|
-
return _regenerator().w(function (
|
|
661
|
-
while (1) switch (
|
|
1045
|
+
_context48.n = 1;
|
|
1046
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee45() {
|
|
1047
|
+
return _regenerator().w(function (_context45) {
|
|
1048
|
+
while (1) switch (_context45.n) {
|
|
662
1049
|
case 0:
|
|
663
|
-
return
|
|
1050
|
+
return _context45.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
664
1051
|
domainId: 5,
|
|
665
1052
|
createCartAndCookie: function createCartAndCookie() {},
|
|
666
1053
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
667
1054
|
})));
|
|
668
1055
|
}
|
|
669
|
-
},
|
|
1056
|
+
}, _callee45);
|
|
670
1057
|
})));
|
|
671
1058
|
case 1:
|
|
672
1059
|
onSuccess = jest.fn(), onError = jest.fn();
|
|
673
|
-
|
|
674
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1060
|
+
_context48.n = 2;
|
|
1061
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee46() {
|
|
675
1062
|
var job;
|
|
676
|
-
return _regenerator().w(function (
|
|
677
|
-
while (1) switch (
|
|
1063
|
+
return _regenerator().w(function (_context46) {
|
|
1064
|
+
while (1) switch (_context46.n) {
|
|
678
1065
|
case 0:
|
|
679
1066
|
job = {
|
|
680
1067
|
product: {
|
|
@@ -685,16 +1072,16 @@ describe('cart load and replacement failures', function () {
|
|
|
685
1072
|
first = window.addCartItem(job, onSuccess, onError);
|
|
686
1073
|
second = window.addCartItem(job, onSuccess, onError);
|
|
687
1074
|
case 1:
|
|
688
|
-
return
|
|
1075
|
+
return _context46.a(2);
|
|
689
1076
|
}
|
|
690
|
-
},
|
|
1077
|
+
}, _callee46);
|
|
691
1078
|
})));
|
|
692
1079
|
case 2:
|
|
693
1080
|
expect(mockCreateItem).not.toHaveBeenCalled();
|
|
694
|
-
|
|
695
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
696
|
-
return _regenerator().w(function (
|
|
697
|
-
while (1) switch (
|
|
1081
|
+
_context48.n = 3;
|
|
1082
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee47() {
|
|
1083
|
+
return _regenerator().w(function (_context47) {
|
|
1084
|
+
while (1) switch (_context47.n) {
|
|
698
1085
|
case 0:
|
|
699
1086
|
finish({
|
|
700
1087
|
cart: {
|
|
@@ -702,12 +1089,12 @@ describe('cart load and replacement failures', function () {
|
|
|
702
1089
|
token: 'new-token'
|
|
703
1090
|
}
|
|
704
1091
|
});
|
|
705
|
-
|
|
1092
|
+
_context47.n = 1;
|
|
706
1093
|
return Promise.all([first, second]);
|
|
707
1094
|
case 1:
|
|
708
|
-
return
|
|
1095
|
+
return _context47.a(2);
|
|
709
1096
|
}
|
|
710
|
-
},
|
|
1097
|
+
}, _callee47);
|
|
711
1098
|
})));
|
|
712
1099
|
case 3:
|
|
713
1100
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
@@ -716,30 +1103,30 @@ describe('cart load and replacement failures', function () {
|
|
|
716
1103
|
})).toEqual([99, 99]);
|
|
717
1104
|
expect(onError).not.toHaveBeenCalled();
|
|
718
1105
|
case 4:
|
|
719
|
-
return
|
|
1106
|
+
return _context48.a(2);
|
|
720
1107
|
}
|
|
721
|
-
},
|
|
1108
|
+
}, _callee48);
|
|
722
1109
|
})));
|
|
723
|
-
it('does not automatically repeat a failed item write after explicit initialization', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1110
|
+
it('does not automatically repeat a failed item write after explicit initialization', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee52() {
|
|
724
1111
|
var onSuccess, onError, job;
|
|
725
|
-
return _regenerator().w(function (
|
|
726
|
-
while (1) switch (
|
|
1112
|
+
return _regenerator().w(function (_context52) {
|
|
1113
|
+
while (1) switch (_context52.n) {
|
|
727
1114
|
case 0:
|
|
728
1115
|
setUserAgent(headlessUserAgent);
|
|
729
1116
|
getCartCookie.mockResolvedValue(undefined);
|
|
730
1117
|
mockCreateItem.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
731
|
-
|
|
732
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
733
|
-
return _regenerator().w(function (
|
|
734
|
-
while (1) switch (
|
|
1118
|
+
_context52.n = 1;
|
|
1119
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee49() {
|
|
1120
|
+
return _regenerator().w(function (_context49) {
|
|
1121
|
+
while (1) switch (_context49.n) {
|
|
735
1122
|
case 0:
|
|
736
|
-
return
|
|
1123
|
+
return _context49.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
737
1124
|
domainId: 5,
|
|
738
1125
|
createCartAndCookie: function createCartAndCookie() {},
|
|
739
1126
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
740
1127
|
})));
|
|
741
1128
|
}
|
|
742
|
-
},
|
|
1129
|
+
}, _callee49);
|
|
743
1130
|
})));
|
|
744
1131
|
case 1:
|
|
745
1132
|
onSuccess = jest.fn(), onError = jest.fn();
|
|
@@ -749,34 +1136,34 @@ describe('cart load and replacement failures', function () {
|
|
|
749
1136
|
},
|
|
750
1137
|
quantity: 100
|
|
751
1138
|
};
|
|
752
|
-
|
|
753
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
754
|
-
return _regenerator().w(function (
|
|
755
|
-
while (1) switch (
|
|
1139
|
+
_context52.n = 2;
|
|
1140
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee50() {
|
|
1141
|
+
return _regenerator().w(function (_context50) {
|
|
1142
|
+
while (1) switch (_context50.n) {
|
|
756
1143
|
case 0:
|
|
757
|
-
|
|
1144
|
+
_context50.n = 1;
|
|
758
1145
|
return window.addCartItem(job, onSuccess, onError);
|
|
759
1146
|
case 1:
|
|
760
|
-
return
|
|
1147
|
+
return _context50.a(2);
|
|
761
1148
|
}
|
|
762
|
-
},
|
|
1149
|
+
}, _callee50);
|
|
763
1150
|
})));
|
|
764
1151
|
case 2:
|
|
765
1152
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
766
1153
|
expect(mockCreateItem).toHaveBeenCalledTimes(1);
|
|
767
1154
|
expect(onSuccess).not.toHaveBeenCalled();
|
|
768
1155
|
expect(onError).toHaveBeenCalledTimes(1);
|
|
769
|
-
|
|
770
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
771
|
-
return _regenerator().w(function (
|
|
772
|
-
while (1) switch (
|
|
1156
|
+
_context52.n = 3;
|
|
1157
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee51() {
|
|
1158
|
+
return _regenerator().w(function (_context51) {
|
|
1159
|
+
while (1) switch (_context51.n) {
|
|
773
1160
|
case 0:
|
|
774
|
-
|
|
1161
|
+
_context51.n = 1;
|
|
775
1162
|
return window.addCartItem(job, onSuccess, onError);
|
|
776
1163
|
case 1:
|
|
777
|
-
return
|
|
1164
|
+
return _context51.a(2);
|
|
778
1165
|
}
|
|
779
|
-
},
|
|
1166
|
+
}, _callee51);
|
|
780
1167
|
})));
|
|
781
1168
|
case 3:
|
|
782
1169
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
@@ -788,14 +1175,14 @@ describe('cart load and replacement failures', function () {
|
|
|
788
1175
|
}
|
|
789
1176
|
});
|
|
790
1177
|
case 4:
|
|
791
|
-
return
|
|
1178
|
+
return _context52.a(2);
|
|
792
1179
|
}
|
|
793
|
-
},
|
|
1180
|
+
}, _callee52);
|
|
794
1181
|
})));
|
|
795
|
-
it('shares cold initialization with opening the modal and concurrent getCart callers', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1182
|
+
it('shares cold initialization with opening the modal and concurrent getCart callers', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee56() {
|
|
796
1183
|
var finish, first, second;
|
|
797
|
-
return _regenerator().w(function (
|
|
798
|
-
while (1) switch (
|
|
1184
|
+
return _regenerator().w(function (_context56) {
|
|
1185
|
+
while (1) switch (_context56.n) {
|
|
799
1186
|
case 0:
|
|
800
1187
|
getCartCookie.mockResolvedValue(undefined);
|
|
801
1188
|
mockPost.mockImplementationOnce(function () {
|
|
@@ -803,40 +1190,40 @@ describe('cart load and replacement failures', function () {
|
|
|
803
1190
|
finish = resolve;
|
|
804
1191
|
});
|
|
805
1192
|
});
|
|
806
|
-
|
|
807
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
808
|
-
return _regenerator().w(function (
|
|
809
|
-
while (1) switch (
|
|
1193
|
+
_context56.n = 1;
|
|
1194
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee53() {
|
|
1195
|
+
return _regenerator().w(function (_context53) {
|
|
1196
|
+
while (1) switch (_context53.n) {
|
|
810
1197
|
case 0:
|
|
811
|
-
return
|
|
1198
|
+
return _context53.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
812
1199
|
domainId: 5,
|
|
813
1200
|
createCartAndCookie: function createCartAndCookie() {},
|
|
814
1201
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
815
1202
|
})));
|
|
816
1203
|
}
|
|
817
|
-
},
|
|
1204
|
+
}, _callee53);
|
|
818
1205
|
})));
|
|
819
1206
|
case 1:
|
|
820
|
-
|
|
821
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
822
|
-
return _regenerator().w(function (
|
|
823
|
-
while (1) switch (
|
|
1207
|
+
_context56.n = 2;
|
|
1208
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee54() {
|
|
1209
|
+
return _regenerator().w(function (_context54) {
|
|
1210
|
+
while (1) switch (_context54.n) {
|
|
824
1211
|
case 0:
|
|
825
1212
|
context.toggleCartModal();
|
|
826
1213
|
first = window.getCart();
|
|
827
1214
|
second = window.getCart();
|
|
828
1215
|
case 1:
|
|
829
|
-
return
|
|
1216
|
+
return _context54.a(2);
|
|
830
1217
|
}
|
|
831
|
-
},
|
|
1218
|
+
}, _callee54);
|
|
832
1219
|
})));
|
|
833
1220
|
case 2:
|
|
834
1221
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
835
1222
|
expect(context.fetchingCart).toBe(true);
|
|
836
|
-
|
|
837
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
838
|
-
return _regenerator().w(function (
|
|
839
|
-
while (1) switch (
|
|
1223
|
+
_context56.n = 3;
|
|
1224
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee55() {
|
|
1225
|
+
return _regenerator().w(function (_context55) {
|
|
1226
|
+
while (1) switch (_context55.n) {
|
|
840
1227
|
case 0:
|
|
841
1228
|
finish({
|
|
842
1229
|
cart: {
|
|
@@ -844,26 +1231,26 @@ describe('cart load and replacement failures', function () {
|
|
|
844
1231
|
token: 'new-token'
|
|
845
1232
|
}
|
|
846
1233
|
});
|
|
847
|
-
|
|
1234
|
+
_context55.n = 1;
|
|
848
1235
|
return Promise.all([first, second]);
|
|
849
1236
|
case 1:
|
|
850
|
-
return
|
|
1237
|
+
return _context55.a(2);
|
|
851
1238
|
}
|
|
852
|
-
},
|
|
1239
|
+
}, _callee55);
|
|
853
1240
|
})));
|
|
854
1241
|
case 3:
|
|
855
1242
|
expect(context.cart.id).toBe(99);
|
|
856
1243
|
expect(context.fetchingCart).toBe(false);
|
|
857
1244
|
expect(setCartCookie).toHaveBeenCalledTimes(1);
|
|
858
1245
|
case 4:
|
|
859
|
-
return
|
|
1246
|
+
return _context56.a(2);
|
|
860
1247
|
}
|
|
861
|
-
},
|
|
1248
|
+
}, _callee56);
|
|
862
1249
|
})));
|
|
863
|
-
it('shares an active saved-cart read and allows a later refresh', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1250
|
+
it('shares an active saved-cart read and allows a later refresh', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61() {
|
|
864
1251
|
var finish, saved, read;
|
|
865
|
-
return _regenerator().w(function (
|
|
866
|
-
while (1) switch (
|
|
1252
|
+
return _regenerator().w(function (_context61) {
|
|
1253
|
+
while (1) switch (_context61.n) {
|
|
867
1254
|
case 0:
|
|
868
1255
|
saved = {
|
|
869
1256
|
toJson: function toJson() {
|
|
@@ -881,116 +1268,116 @@ describe('cart load and replacement failures', function () {
|
|
|
881
1268
|
finish = resolve;
|
|
882
1269
|
});
|
|
883
1270
|
}).mockResolvedValue(saved);
|
|
884
|
-
|
|
885
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
886
|
-
return _regenerator().w(function (
|
|
887
|
-
while (1) switch (
|
|
1271
|
+
_context61.n = 1;
|
|
1272
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee57() {
|
|
1273
|
+
return _regenerator().w(function (_context57) {
|
|
1274
|
+
while (1) switch (_context57.n) {
|
|
888
1275
|
case 0:
|
|
889
|
-
return
|
|
1276
|
+
return _context57.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
890
1277
|
domainId: 5,
|
|
891
1278
|
createCartAndCookie: function createCartAndCookie() {},
|
|
892
1279
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
893
1280
|
})));
|
|
894
1281
|
}
|
|
895
|
-
},
|
|
1282
|
+
}, _callee57);
|
|
896
1283
|
})));
|
|
897
1284
|
case 1:
|
|
898
|
-
|
|
899
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
900
|
-
return _regenerator().w(function (
|
|
901
|
-
while (1) switch (
|
|
1285
|
+
_context61.n = 2;
|
|
1286
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee58() {
|
|
1287
|
+
return _regenerator().w(function (_context58) {
|
|
1288
|
+
while (1) switch (_context58.n) {
|
|
902
1289
|
case 0:
|
|
903
1290
|
context.toggleCartModal();
|
|
904
1291
|
read = window.getCart();
|
|
905
1292
|
case 1:
|
|
906
|
-
return
|
|
1293
|
+
return _context58.a(2);
|
|
907
1294
|
}
|
|
908
|
-
},
|
|
1295
|
+
}, _callee58);
|
|
909
1296
|
})));
|
|
910
1297
|
case 2:
|
|
911
1298
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
912
|
-
|
|
913
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
914
|
-
return _regenerator().w(function (
|
|
915
|
-
while (1) switch (
|
|
1299
|
+
_context61.n = 3;
|
|
1300
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee59() {
|
|
1301
|
+
return _regenerator().w(function (_context59) {
|
|
1302
|
+
while (1) switch (_context59.n) {
|
|
916
1303
|
case 0:
|
|
917
1304
|
finish(saved);
|
|
918
|
-
|
|
1305
|
+
_context59.n = 1;
|
|
919
1306
|
return read;
|
|
920
1307
|
case 1:
|
|
921
|
-
return
|
|
1308
|
+
return _context59.a(2);
|
|
922
1309
|
}
|
|
923
|
-
},
|
|
1310
|
+
}, _callee59);
|
|
924
1311
|
})));
|
|
925
1312
|
case 3:
|
|
926
|
-
|
|
927
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
928
|
-
return _regenerator().w(function (
|
|
929
|
-
while (1) switch (
|
|
1313
|
+
_context61.n = 4;
|
|
1314
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee60() {
|
|
1315
|
+
return _regenerator().w(function (_context60) {
|
|
1316
|
+
while (1) switch (_context60.n) {
|
|
930
1317
|
case 0:
|
|
931
|
-
|
|
1318
|
+
_context60.n = 1;
|
|
932
1319
|
return window.getCart();
|
|
933
1320
|
case 1:
|
|
934
|
-
return
|
|
1321
|
+
return _context60.a(2);
|
|
935
1322
|
}
|
|
936
|
-
},
|
|
1323
|
+
}, _callee60);
|
|
937
1324
|
})));
|
|
938
1325
|
case 4:
|
|
939
1326
|
expect(mockGet).toHaveBeenCalledTimes(2);
|
|
940
1327
|
expect(mockPost).not.toHaveBeenCalled();
|
|
941
1328
|
expect(context.cart.cartItems).toHaveLength(1);
|
|
942
1329
|
case 5:
|
|
943
|
-
return
|
|
1330
|
+
return _context61.a(2);
|
|
944
1331
|
}
|
|
945
|
-
},
|
|
1332
|
+
}, _callee61);
|
|
946
1333
|
})));
|
|
947
|
-
it('releases failed initialization so an explicit retry can create the cart', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
948
|
-
return _regenerator().w(function (
|
|
949
|
-
while (1) switch (
|
|
1334
|
+
it('releases failed initialization so an explicit retry can create the cart', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64() {
|
|
1335
|
+
return _regenerator().w(function (_context64) {
|
|
1336
|
+
while (1) switch (_context64.n) {
|
|
950
1337
|
case 0:
|
|
951
1338
|
getCartCookie.mockResolvedValue(undefined);
|
|
952
1339
|
mockPost.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
953
|
-
|
|
954
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
955
|
-
return _regenerator().w(function (
|
|
956
|
-
while (1) switch (
|
|
1340
|
+
_context64.n = 1;
|
|
1341
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62() {
|
|
1342
|
+
return _regenerator().w(function (_context62) {
|
|
1343
|
+
while (1) switch (_context62.n) {
|
|
957
1344
|
case 0:
|
|
958
|
-
return
|
|
1345
|
+
return _context62.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
959
1346
|
domainId: 5,
|
|
960
1347
|
createCartAndCookie: function createCartAndCookie() {},
|
|
961
1348
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
962
1349
|
})));
|
|
963
1350
|
}
|
|
964
|
-
},
|
|
1351
|
+
}, _callee62);
|
|
965
1352
|
})));
|
|
966
1353
|
case 1:
|
|
967
1354
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
968
1355
|
expect(context.fetchingCart).toBe(false);
|
|
969
|
-
|
|
970
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
971
|
-
return _regenerator().w(function (
|
|
972
|
-
while (1) switch (
|
|
1356
|
+
_context64.n = 2;
|
|
1357
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63() {
|
|
1358
|
+
return _regenerator().w(function (_context63) {
|
|
1359
|
+
while (1) switch (_context63.n) {
|
|
973
1360
|
case 0:
|
|
974
|
-
|
|
1361
|
+
_context63.n = 1;
|
|
975
1362
|
return Promise.all([window.getCart(), window.getCart()]);
|
|
976
1363
|
case 1:
|
|
977
|
-
return
|
|
1364
|
+
return _context63.a(2);
|
|
978
1365
|
}
|
|
979
|
-
},
|
|
1366
|
+
}, _callee63);
|
|
980
1367
|
})));
|
|
981
1368
|
case 2:
|
|
982
1369
|
expect(mockPost).toHaveBeenCalledTimes(2);
|
|
983
1370
|
expect(context.cart.id).toBe(99);
|
|
984
1371
|
expect(context.fetchingCart).toBe(false);
|
|
985
1372
|
case 3:
|
|
986
|
-
return
|
|
1373
|
+
return _context64.a(2);
|
|
987
1374
|
}
|
|
988
|
-
},
|
|
1375
|
+
}, _callee64);
|
|
989
1376
|
})));
|
|
990
|
-
it('initializes a changed domain independently of the previous pending domain', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1377
|
+
it('initializes a changed domain independently of the previous pending domain', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70() {
|
|
991
1378
|
var finish, view, current;
|
|
992
|
-
return _regenerator().w(function (
|
|
993
|
-
while (1) switch (
|
|
1379
|
+
return _regenerator().w(function (_context70) {
|
|
1380
|
+
while (1) switch (_context70.n) {
|
|
994
1381
|
case 0:
|
|
995
1382
|
finish = {};
|
|
996
1383
|
getCartCookie.mockImplementation(function (id) {
|
|
@@ -1008,33 +1395,33 @@ describe('cart load and replacement failures', function () {
|
|
|
1008
1395
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
1009
1396
|
});
|
|
1010
1397
|
};
|
|
1011
|
-
|
|
1012
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1013
|
-
return _regenerator().w(function (
|
|
1014
|
-
while (1) switch (
|
|
1398
|
+
_context70.n = 1;
|
|
1399
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65() {
|
|
1400
|
+
return _regenerator().w(function (_context65) {
|
|
1401
|
+
while (1) switch (_context65.n) {
|
|
1015
1402
|
case 0:
|
|
1016
|
-
return
|
|
1403
|
+
return _context65.a(2, root.render(view(5)));
|
|
1017
1404
|
}
|
|
1018
|
-
},
|
|
1405
|
+
}, _callee65);
|
|
1019
1406
|
})));
|
|
1020
1407
|
case 1:
|
|
1021
|
-
|
|
1022
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1023
|
-
return _regenerator().w(function (
|
|
1024
|
-
while (1) switch (
|
|
1408
|
+
_context70.n = 2;
|
|
1409
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66() {
|
|
1410
|
+
return _regenerator().w(function (_context66) {
|
|
1411
|
+
while (1) switch (_context66.n) {
|
|
1025
1412
|
case 0:
|
|
1026
|
-
return
|
|
1413
|
+
return _context66.a(2, root.render(view(6)));
|
|
1027
1414
|
}
|
|
1028
|
-
},
|
|
1415
|
+
}, _callee66);
|
|
1029
1416
|
})));
|
|
1030
1417
|
case 2:
|
|
1031
1418
|
expect(mockGet).toHaveBeenCalledTimes(2);
|
|
1032
|
-
|
|
1033
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1034
|
-
return _regenerator().w(function (
|
|
1035
|
-
while (1) switch (
|
|
1419
|
+
_context70.n = 3;
|
|
1420
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67() {
|
|
1421
|
+
return _regenerator().w(function (_context67) {
|
|
1422
|
+
while (1) switch (_context67.n) {
|
|
1036
1423
|
case 0:
|
|
1037
|
-
return
|
|
1424
|
+
return _context67.a(2, finish[5]({
|
|
1038
1425
|
toJson: function toJson() {
|
|
1039
1426
|
return {
|
|
1040
1427
|
id: 5,
|
|
@@ -1043,26 +1430,26 @@ describe('cart load and replacement failures', function () {
|
|
|
1043
1430
|
}
|
|
1044
1431
|
}));
|
|
1045
1432
|
}
|
|
1046
|
-
},
|
|
1433
|
+
}, _callee67);
|
|
1047
1434
|
})));
|
|
1048
1435
|
case 3:
|
|
1049
|
-
|
|
1050
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1051
|
-
return _regenerator().w(function (
|
|
1052
|
-
while (1) switch (
|
|
1436
|
+
_context70.n = 4;
|
|
1437
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68() {
|
|
1438
|
+
return _regenerator().w(function (_context68) {
|
|
1439
|
+
while (1) switch (_context68.n) {
|
|
1053
1440
|
case 0:
|
|
1054
1441
|
current = window.getCart();
|
|
1055
1442
|
case 1:
|
|
1056
|
-
return
|
|
1443
|
+
return _context68.a(2);
|
|
1057
1444
|
}
|
|
1058
|
-
},
|
|
1445
|
+
}, _callee68);
|
|
1059
1446
|
})));
|
|
1060
1447
|
case 4:
|
|
1061
1448
|
expect(mockGet).toHaveBeenCalledTimes(2);
|
|
1062
|
-
|
|
1063
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1064
|
-
return _regenerator().w(function (
|
|
1065
|
-
while (1) switch (
|
|
1449
|
+
_context70.n = 5;
|
|
1450
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69() {
|
|
1451
|
+
return _regenerator().w(function (_context69) {
|
|
1452
|
+
while (1) switch (_context69.n) {
|
|
1066
1453
|
case 0:
|
|
1067
1454
|
finish[6]({
|
|
1068
1455
|
toJson: function toJson() {
|
|
@@ -1072,19 +1459,19 @@ describe('cart load and replacement failures', function () {
|
|
|
1072
1459
|
};
|
|
1073
1460
|
}
|
|
1074
1461
|
});
|
|
1075
|
-
|
|
1462
|
+
_context69.n = 1;
|
|
1076
1463
|
return current;
|
|
1077
1464
|
case 1:
|
|
1078
|
-
return
|
|
1465
|
+
return _context69.a(2);
|
|
1079
1466
|
}
|
|
1080
|
-
},
|
|
1467
|
+
}, _callee69);
|
|
1081
1468
|
})));
|
|
1082
1469
|
case 5:
|
|
1083
1470
|
expect(context.cart.id).toBe(6);
|
|
1084
1471
|
case 6:
|
|
1085
|
-
return
|
|
1472
|
+
return _context70.a(2);
|
|
1086
1473
|
}
|
|
1087
|
-
},
|
|
1474
|
+
}, _callee70);
|
|
1088
1475
|
})));
|
|
1089
1476
|
it.each([new TypeError('Load failed'), {
|
|
1090
1477
|
statusCode: 502,
|
|
@@ -1093,11 +1480,11 @@ describe('cart load and replacement failures', function () {
|
|
|
1093
1480
|
statusCode: 403,
|
|
1094
1481
|
message: 'Forbidden'
|
|
1095
1482
|
}])('preserves the saved cart and never POSTs a replacement after %s', /*#__PURE__*/function () {
|
|
1096
|
-
var
|
|
1097
|
-
return _regenerator().w(function (
|
|
1098
|
-
while (1) switch (
|
|
1483
|
+
var _ref71 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(error) {
|
|
1484
|
+
return _regenerator().w(function (_context71) {
|
|
1485
|
+
while (1) switch (_context71.n) {
|
|
1099
1486
|
case 0:
|
|
1100
|
-
|
|
1487
|
+
_context71.n = 1;
|
|
1101
1488
|
return mount(error);
|
|
1102
1489
|
case 1:
|
|
1103
1490
|
expect(getCartCookie).toHaveBeenCalledWith(5);
|
|
@@ -1113,20 +1500,20 @@ describe('cart load and replacement failures', function () {
|
|
|
1113
1500
|
expect(context.fetchingCart).toBe(false);
|
|
1114
1501
|
expect(reportCartFailure).toHaveBeenCalledWith(error, CART_FAILURE_SOURCES.load);
|
|
1115
1502
|
case 2:
|
|
1116
|
-
return
|
|
1503
|
+
return _context71.a(2);
|
|
1117
1504
|
}
|
|
1118
|
-
},
|
|
1505
|
+
}, _callee71);
|
|
1119
1506
|
}));
|
|
1120
1507
|
return function (_x3) {
|
|
1121
|
-
return
|
|
1508
|
+
return _ref71.apply(this, arguments);
|
|
1122
1509
|
};
|
|
1123
1510
|
}());
|
|
1124
1511
|
it.each([404, 410])('replaces a genuinely missing cart after HTTP %s', /*#__PURE__*/function () {
|
|
1125
|
-
var
|
|
1126
|
-
return _regenerator().w(function (
|
|
1127
|
-
while (1) switch (
|
|
1512
|
+
var _ref72 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(statusCode) {
|
|
1513
|
+
return _regenerator().w(function (_context72) {
|
|
1514
|
+
while (1) switch (_context72.n) {
|
|
1128
1515
|
case 0:
|
|
1129
|
-
|
|
1516
|
+
_context72.n = 1;
|
|
1130
1517
|
return mount({
|
|
1131
1518
|
statusCode: statusCode
|
|
1132
1519
|
});
|
|
@@ -1137,19 +1524,19 @@ describe('cart load and replacement failures', function () {
|
|
|
1137
1524
|
}));
|
|
1138
1525
|
expect(setCartCookie).toHaveBeenCalledTimes(1);
|
|
1139
1526
|
case 2:
|
|
1140
|
-
return
|
|
1527
|
+
return _context72.a(2);
|
|
1141
1528
|
}
|
|
1142
|
-
},
|
|
1529
|
+
}, _callee72);
|
|
1143
1530
|
}));
|
|
1144
1531
|
return function (_x4) {
|
|
1145
|
-
return
|
|
1532
|
+
return _ref72.apply(this, arguments);
|
|
1146
1533
|
};
|
|
1147
1534
|
}());
|
|
1148
|
-
it('allows an explicit retry to restore the same cart without creating another', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1149
|
-
return _regenerator().w(function (
|
|
1150
|
-
while (1) switch (
|
|
1535
|
+
it('allows an explicit retry to restore the same cart without creating another', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74() {
|
|
1536
|
+
return _regenerator().w(function (_context74) {
|
|
1537
|
+
while (1) switch (_context74.n) {
|
|
1151
1538
|
case 0:
|
|
1152
|
-
|
|
1539
|
+
_context74.n = 1;
|
|
1153
1540
|
return mount(new TypeError('Load failed'));
|
|
1154
1541
|
case 1:
|
|
1155
1542
|
mockGet.mockResolvedValue({
|
|
@@ -1163,50 +1550,50 @@ describe('cart load and replacement failures', function () {
|
|
|
1163
1550
|
};
|
|
1164
1551
|
}
|
|
1165
1552
|
});
|
|
1166
|
-
|
|
1167
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1168
|
-
return _regenerator().w(function (
|
|
1169
|
-
while (1) switch (
|
|
1553
|
+
_context74.n = 2;
|
|
1554
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73() {
|
|
1555
|
+
return _regenerator().w(function (_context73) {
|
|
1556
|
+
while (1) switch (_context73.n) {
|
|
1170
1557
|
case 0:
|
|
1171
|
-
|
|
1558
|
+
_context73.n = 1;
|
|
1172
1559
|
return window.getCart();
|
|
1173
1560
|
case 1:
|
|
1174
|
-
return
|
|
1561
|
+
return _context73.a(2);
|
|
1175
1562
|
}
|
|
1176
|
-
},
|
|
1563
|
+
}, _callee73);
|
|
1177
1564
|
})));
|
|
1178
1565
|
case 2:
|
|
1179
1566
|
expect(context.cart.id).toBe(42);
|
|
1180
1567
|
expect(context.cart.cartItems).toHaveLength(1);
|
|
1181
1568
|
expect(mockPost).not.toHaveBeenCalled();
|
|
1182
1569
|
case 3:
|
|
1183
|
-
return
|
|
1570
|
+
return _context74.a(2);
|
|
1184
1571
|
}
|
|
1185
|
-
},
|
|
1572
|
+
}, _callee74);
|
|
1186
1573
|
})));
|
|
1187
1574
|
it.each([new TypeError('Failed to fetch'), {
|
|
1188
1575
|
statusCode: 503,
|
|
1189
1576
|
message: 'Service unavailable'
|
|
1190
1577
|
}, null, undefined])('keeps the clear-cart panel and saved cart when replacement fails with %s', /*#__PURE__*/function () {
|
|
1191
|
-
var
|
|
1192
|
-
return _regenerator().w(function (
|
|
1193
|
-
while (1) switch (
|
|
1578
|
+
var _ref75 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(error) {
|
|
1579
|
+
return _regenerator().w(function (_context76) {
|
|
1580
|
+
while (1) switch (_context76.n) {
|
|
1194
1581
|
case 0:
|
|
1195
|
-
|
|
1582
|
+
_context76.n = 1;
|
|
1196
1583
|
return mountSavedCart();
|
|
1197
1584
|
case 1:
|
|
1198
1585
|
mockPost.mockRejectedValueOnce(error);
|
|
1199
|
-
|
|
1200
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1201
|
-
return _regenerator().w(function (
|
|
1202
|
-
while (1) switch (
|
|
1586
|
+
_context76.n = 2;
|
|
1587
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75() {
|
|
1588
|
+
return _regenerator().w(function (_context75) {
|
|
1589
|
+
while (1) switch (_context75.n) {
|
|
1203
1590
|
case 0:
|
|
1204
|
-
|
|
1591
|
+
_context75.n = 1;
|
|
1205
1592
|
return context.clearCart();
|
|
1206
1593
|
case 1:
|
|
1207
|
-
return
|
|
1594
|
+
return _context75.a(2);
|
|
1208
1595
|
}
|
|
1209
|
-
},
|
|
1596
|
+
}, _callee75);
|
|
1210
1597
|
})));
|
|
1211
1598
|
case 2:
|
|
1212
1599
|
expect(context.activeTabIndex).toBe(tabIdClearCart);
|
|
@@ -1224,47 +1611,47 @@ describe('cart load and replacement failures', function () {
|
|
|
1224
1611
|
expect(context.alert.message).toBe((error === null || error === void 0 ? void 0 : error.message) || 'Unable to fetch cart.');
|
|
1225
1612
|
expect(context.fetchingCart).toBe(false);
|
|
1226
1613
|
case 3:
|
|
1227
|
-
return
|
|
1614
|
+
return _context76.a(2);
|
|
1228
1615
|
}
|
|
1229
|
-
},
|
|
1616
|
+
}, _callee76);
|
|
1230
1617
|
}));
|
|
1231
1618
|
return function (_x5) {
|
|
1232
|
-
return
|
|
1619
|
+
return _ref75.apply(this, arguments);
|
|
1233
1620
|
};
|
|
1234
1621
|
}());
|
|
1235
|
-
it('finishes clearing only after an explicit retry successfully creates the replacement', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1236
|
-
return _regenerator().w(function (
|
|
1237
|
-
while (1) switch (
|
|
1622
|
+
it('finishes clearing only after an explicit retry successfully creates the replacement', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79() {
|
|
1623
|
+
return _regenerator().w(function (_context79) {
|
|
1624
|
+
while (1) switch (_context79.n) {
|
|
1238
1625
|
case 0:
|
|
1239
|
-
|
|
1626
|
+
_context79.n = 1;
|
|
1240
1627
|
return mountSavedCart();
|
|
1241
1628
|
case 1:
|
|
1242
1629
|
mockPost.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
1243
|
-
|
|
1244
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1245
|
-
return _regenerator().w(function (
|
|
1246
|
-
while (1) switch (
|
|
1630
|
+
_context79.n = 2;
|
|
1631
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77() {
|
|
1632
|
+
return _regenerator().w(function (_context77) {
|
|
1633
|
+
while (1) switch (_context77.n) {
|
|
1247
1634
|
case 0:
|
|
1248
|
-
|
|
1635
|
+
_context77.n = 1;
|
|
1249
1636
|
return context.clearCart();
|
|
1250
1637
|
case 1:
|
|
1251
|
-
return
|
|
1638
|
+
return _context77.a(2);
|
|
1252
1639
|
}
|
|
1253
|
-
},
|
|
1640
|
+
}, _callee77);
|
|
1254
1641
|
})));
|
|
1255
1642
|
case 2:
|
|
1256
1643
|
expect(context.activeTabIndex).toBe(tabIdClearCart);
|
|
1257
|
-
|
|
1258
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1259
|
-
return _regenerator().w(function (
|
|
1260
|
-
while (1) switch (
|
|
1644
|
+
_context79.n = 3;
|
|
1645
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78() {
|
|
1646
|
+
return _regenerator().w(function (_context78) {
|
|
1647
|
+
while (1) switch (_context78.n) {
|
|
1261
1648
|
case 0:
|
|
1262
|
-
|
|
1649
|
+
_context78.n = 1;
|
|
1263
1650
|
return context.clearCart();
|
|
1264
1651
|
case 1:
|
|
1265
|
-
return
|
|
1652
|
+
return _context78.a(2);
|
|
1266
1653
|
}
|
|
1267
|
-
},
|
|
1654
|
+
}, _callee78);
|
|
1268
1655
|
})));
|
|
1269
1656
|
case 3:
|
|
1270
1657
|
expect(mockPost).toHaveBeenCalledTimes(2);
|
|
@@ -1274,8 +1661,8 @@ describe('cart load and replacement failures', function () {
|
|
|
1274
1661
|
expect(context.alert.show).toBe(false);
|
|
1275
1662
|
expect(context.fetchingCart).toBe(false);
|
|
1276
1663
|
case 4:
|
|
1277
|
-
return
|
|
1664
|
+
return _context79.a(2);
|
|
1278
1665
|
}
|
|
1279
|
-
},
|
|
1666
|
+
}, _callee79);
|
|
1280
1667
|
})));
|
|
1281
1668
|
});
|