Skip to content

Commit 6d4cad4

Browse files
committed
ACP2E-1143: trigger tax / subtotal estimates refresh on shipping address updates; jasmine unit test update
1 parent 9486405 commit 6d4cad4

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ define([
3838
cartCache.get('rates')
3939
) {
4040
shippingService.setShippingRates(cartCache.get('rates'));
41-
41+
quote.setTotals(cartCache.get('cart-data').totals);
4242
return;
4343
}
4444

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/estimate-service.test.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,21 @@ define([
2020

2121
var injector = new Squire(),
2222
rates = 'flatrate',
23+
totals = {
24+
tax: 0.1,
25+
totals: 10
26+
},
27+
cartData = {
28+
totals: totals,
29+
rates: null
30+
},
2331
mocks = {
2432
'Magento_Checkout/js/model/quote': {
2533
shippingAddress: ko.observable(),
2634
isVirtual: function () {},
2735
billingAddress: ko.observable(),
28-
shippingMethod: ko.observable()
29-
36+
shippingMethod: ko.observable(),
37+
setTotals: function () {}
3038
},
3139
'Magento_Checkout/js/model/shipping-rate-processor/new-address': {
3240
getRates: jasmine.createSpy()
@@ -42,7 +50,7 @@ define([
4250
},
4351
'Magento_Checkout/js/model/cart/cache': {
4452
isChanged: function () {},
45-
get: jasmine.createSpy().and.returnValue(rates),
53+
get: jasmine.createSpy().and.returnValues(rates, cartData),
4654
set: jasmine.createSpy()
4755
},
4856
'Magento_Customer/js/customer-data': {
@@ -90,13 +98,16 @@ define([
9098
spyOn(mocks['Magento_Checkout/js/model/quote'], 'isVirtual').and.returnValue(false);
9199
spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'isChanged').and.returnValue(false);
92100
spyOn(mocks['Magento_Checkout/js/model/shipping-service'], 'setShippingRates');
101+
spyOn(mocks['Magento_Checkout/js/model/quote'], 'setTotals');
93102
mocks['Magento_Checkout/js/model/quote'].shippingAddress({
94103
id: 2,
95104
getType: function () {
96105
return 'address_type_test';
97106
}
98107
});
108+
expect(mocks['Magento_Checkout/js/model/cart/cache'].get('cart-data')).toBe(cartData);
99109
expect(mocks['Magento_Checkout/js/model/shipping-service'].setShippingRates).toHaveBeenCalledWith(rates);
110+
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(cartData.totals);
100111
expect(mocks['Magento_Checkout/js/model/cart/totals-processor/default'].estimateTotals)
101112
.not.toHaveBeenCalled();
102113
expect(mocks['Magento_Checkout/js/model/shipping-rate-processor/new-address'].getRates)

0 commit comments

Comments
 (0)