Skip to content

Commit 7103e93

Browse files
MAGETWO-64834: Spinner is Always Displayed on Shopping Cart page in Summary block for virtual quote
- JS unit test update
1 parent 1ba5487 commit 7103e93

File tree

2 files changed

+15
-12
lines changed
  • app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor
  • dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor

2 files changed

+15
-12
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ define([
4949
shippingCarrierCode: null
5050
};
5151

52-
if (quote.shippingMethod()) {
52+
if (quote.shippingMethod() && quote.shippingMethod()['method_code']) {
5353
data.shippingMethodCode = quote.shippingMethod()['method_code'];
5454
data.shippingCarrierCode = quote.shippingMethod()['carrier_code'];
5555
}
@@ -82,7 +82,7 @@ define([
8282
shippingCarrierCode: null
8383
};
8484

85-
if (quote.shippingMethod()) {
85+
if (quote.shippingMethod() && quote.shippingMethod()['method_code']) {
8686
data.shippingMethodCode = quote.shippingMethod()['method_code'];
8787
data.shippingCarrierCode = quote.shippingMethod()['carrier_code'];
8888
}

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ define([
3232
regionId: 'California',
3333
postcode: 90210
3434
},
35+
data = {
36+
totals: result,
37+
address: address,
38+
cartVersion: 1,
39+
shippingMethodCode: null,
40+
shippingCarrierCode: null
41+
},
3542
mocks = {
3643
'Magento_Checkout/js/model/resource-url-manager': {
3744
getUrlForTotalsEstimationForNewAddress: jasmine.createSpy().and.returnValue(
@@ -42,8 +49,7 @@ define([
4249
shippingMethod: ko.observable({
4350
'method_code': 'flatrate',
4451
'carrier_code': 'flatrate'
45-
}
46-
),
52+
}),
4753
setTotals: jasmine.createSpy()
4854
},
4955
'mage/storage': {
@@ -64,14 +70,8 @@ define([
6470
get: function () {
6571
},
6672
set: jasmine.createSpy()
67-
}
68-
},
69-
data = {
70-
totals: result,
71-
address: address,
72-
cartVersion: 1,
73-
shippingMethodCode: 'flatrate',
74-
shippingCarrierCode: 'flatrate'
73+
},
74+
data: data
7575
},
7676
defaultProcessor;
7777

@@ -112,6 +112,9 @@ define([
112112
);
113113
spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'get');
114114
spyOn(mocks['mage/storage'], 'post').and.callFake(function () {
115+
data.shippingMethodCode = mocks['Magento_Checkout/js/model/quote'].shippingMethod()['method_code'];
116+
data.shippingCarrierCode = mocks['Magento_Checkout/js/model/quote'].shippingMethod()['carrier_code'];
117+
115118
return new $.Deferred().resolve(result);
116119
});
117120
expect(defaultProcessor.estimateTotals(address)).toBeUndefined();

0 commit comments

Comments
 (0)