@@ -12,7 +12,7 @@ require.config({
12
12
}
13
13
} ) ;
14
14
15
- define ( [ 'squire' , 'ko' , 'jquery' , 'jquery/validate' ] , function ( Squire , ko , $ ) {
15
+ define ( [ 'squire' , 'ko' , 'jquery' , 'uiRegistry' , ' jquery/validate'] , function ( Squire , ko , $ , registry ) {
16
16
'use strict' ;
17
17
18
18
var injector = new Squire ( ) ,
@@ -28,7 +28,17 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
28
28
'Magento_Checkout/js/model/address-converter' : jasmine . createSpy ( ) ,
29
29
'Magento_Checkout/js/model/quote' : {
30
30
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
+ }
32
42
} ,
33
43
'Magento_Checkout/js/action/create-shipping-address' : jasmine . createSpy ( ) . and . returnValue (
34
44
jasmine . createSpyObj ( 'newShippingAddress' , [ 'getKey' ] )
@@ -52,7 +62,7 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
52
62
'checkoutData' ,
53
63
[ 'setSelectedShippingAddress' , 'setNewCustomerShippingAddress' , 'setSelectedShippingRate' ]
54
64
) ,
55
- 'uiRegistry ' : jasmine . createSpy ( ) ,
65
+ 'Magento_Ui/js/lib/registry/registry ' : registry ,
56
66
'Magento_Checkout/js/model/shipping-rate-service' : jasmine . createSpy ( )
57
67
} ,
58
68
obj ;
@@ -63,6 +73,7 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
63
73
obj = new Constr ( {
64
74
provider : 'provName' ,
65
75
name : '' ,
76
+ parentName : 'test' ,
66
77
index : '' ,
67
78
popUpForm : {
68
79
options : {
@@ -156,12 +167,26 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
156
167
157
168
describe ( '"setShippingInformation" method' , function ( ) {
158
169
it ( 'Check method call.' , function ( ) {
170
+ spyOn ( obj , 'validateShippingInformation' ) . and . returnValue ( false ) ;
159
171
expect ( obj . setShippingInformation ( ) ) . toBeUndefined ( ) ;
160
172
} ) ;
161
173
} ) ;
162
174
163
175
describe ( '"validateShippingInformation" method' , function ( ) {
164
176
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' , { } ) ;
165
190
obj . source = {
166
191
get : jasmine . createSpy ( ) . and . returnValue ( true ) ,
167
192
set : jasmine . createSpy ( ) ,
0 commit comments