Skip to content

Commit 74e4bec

Browse files
committed
ENGCOM-3386: #18990: Shipping address is not validated in checkout… #19038. Fix unit test.
1 parent dc996fe commit 74e4bec

File tree

1 file changed

+28
-3
lines changed
  • dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view

1 file changed

+28
-3
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/shipping.test.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require.config({
1212
}
1313
});
1414

15-
define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
15+
define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Squire, ko, $, registry) {
1616
'use strict';
1717

1818
var injector = new Squire(),
@@ -28,7 +28,17 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
2828
'Magento_Checkout/js/model/address-converter': jasmine.createSpy(),
2929
'Magento_Checkout/js/model/quote': {
3030
isVirtual: jasmine.createSpy(),
31-
shippingMethod: ko.observable()
31+
shippingMethod: ko.observable(),
32+
33+
/**
34+
* Stub
35+
*/
36+
shippingAddress: function () {
37+
38+
return {
39+
'countryId': 'AD'
40+
};
41+
}
3242
},
3343
'Magento_Checkout/js/action/create-shipping-address': jasmine.createSpy().and.returnValue(
3444
jasmine.createSpyObj('newShippingAddress', ['getKey'])
@@ -52,7 +62,7 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
5262
'checkoutData',
5363
['setSelectedShippingAddress', 'setNewCustomerShippingAddress', 'setSelectedShippingRate']
5464
),
55-
'uiRegistry': jasmine.createSpy(),
65+
'Magento_Ui/js/lib/registry/registry': registry,
5666
'Magento_Checkout/js/model/shipping-rate-service': jasmine.createSpy()
5767
},
5868
obj;
@@ -63,6 +73,7 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
6373
obj = new Constr({
6474
provider: 'provName',
6575
name: '',
76+
parentName: 'test',
6677
index: '',
6778
popUpForm: {
6879
options: {
@@ -156,12 +167,26 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
156167

157168
describe('"setShippingInformation" method', function () {
158169
it('Check method call.', function () {
170+
spyOn(obj, 'validateShippingInformation').and.returnValue(false);
159171
expect(obj.setShippingInformation()).toBeUndefined();
160172
});
161173
});
162174

163175
describe('"validateShippingInformation" method', function () {
164176
it('Check method call on negative cases.', function () {
177+
var country = {
178+
'indexedOptions': {
179+
'AD':
180+
{
181+
label: 'Andorra',
182+
labeltitle: 'Andorra',
183+
value: 'AD'
184+
}
185+
}
186+
};
187+
188+
registry.set('test.shippingAddress.shipping-address-fieldset.country_id', country);
189+
registry.set('checkout.errors', {});
165190
obj.source = {
166191
get: jasmine.createSpy().and.returnValue(true),
167192
set: jasmine.createSpy(),

0 commit comments

Comments
 (0)