@@ -12,14 +12,24 @@ require.config({
12
12
}
13
13
} ) ;
14
14
15
- define ( [ 'squire' , 'ko' , 'jquery' , 'uiRegistry' , ' jquery/validate'] , function ( Squire , ko , $ , registry ) {
15
+ define ( [ 'squire' , 'ko' , 'jquery' , 'jquery/validate' ] , function ( Squire , ko , $ ) {
16
16
'use strict' ;
17
17
18
18
var injector = new Squire ( ) ,
19
19
modalStub = {
20
20
openModal : jasmine . createSpy ( ) ,
21
21
closeModal : jasmine . createSpy ( )
22
22
} ,
23
+ country = {
24
+ /** Stub */
25
+ on : function ( ) { } ,
26
+
27
+ /** Stub */
28
+ get : function ( ) { } ,
29
+
30
+ /** Stub */
31
+ set : function ( ) { }
32
+ } ,
23
33
mocks = {
24
34
'Magento_Customer/js/model/customer' : {
25
35
isLoggedIn : ko . observable ( )
@@ -28,17 +38,7 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
28
38
'Magento_Checkout/js/model/address-converter' : jasmine . createSpy ( ) ,
29
39
'Magento_Checkout/js/model/quote' : {
30
40
isVirtual : jasmine . createSpy ( ) ,
31
- shippingMethod : ko . observable ( ) ,
32
-
33
- /**
34
- * Stub
35
- */
36
- shippingAddress : function ( ) {
37
-
38
- return {
39
- 'countryId' : 'AD'
40
- } ;
41
- }
41
+ shippingMethod : ko . observable ( )
42
42
} ,
43
43
'Magento_Checkout/js/action/create-shipping-address' : jasmine . createSpy ( ) . and . returnValue (
44
44
jasmine . createSpyObj ( 'newShippingAddress' , [ 'getKey' ] )
@@ -62,7 +62,18 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
62
62
'checkoutData' ,
63
63
[ 'setSelectedShippingAddress' , 'setNewCustomerShippingAddress' , 'setSelectedShippingRate' ]
64
64
) ,
65
- 'Magento_Ui/js/lib/registry/registry' : registry ,
65
+ 'Magento_Ui/js/lib/registry/registry' : {
66
+ async : jasmine . createSpy ( ) . and . returnValue ( function ( ) { } ) ,
67
+ create : jasmine . createSpy ( ) ,
68
+ set : jasmine . createSpy ( ) ,
69
+ get : jasmine . createSpy ( ) . and . callFake ( function ( query ) {
70
+ if ( query === 'test.shippingAddress.shipping-address-fieldset.country_id' ) {
71
+ return country ;
72
+ } else if ( query === 'checkout.errors' ) {
73
+ return { } ;
74
+ }
75
+ } )
76
+ } ,
66
77
'Magento_Checkout/js/model/shipping-rate-service' : jasmine . createSpy ( )
67
78
} ,
68
79
obj ;
@@ -73,7 +84,6 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
73
84
obj = new Constr ( {
74
85
provider : 'provName' ,
75
86
name : '' ,
76
- parentName : 'test' ,
77
87
index : '' ,
78
88
popUpForm : {
79
89
options : {
@@ -174,16 +184,6 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
174
184
175
185
describe ( '"validateShippingInformation" method' , function ( ) {
176
186
it ( 'Check method call on negative cases.' , function ( ) {
177
- /* jscs:disable */
178
- var country = {
179
- on : function ( ) { } ,
180
- get : function ( ) { } ,
181
- set : function ( ) { }
182
- } ;
183
- /* jscs:enable */
184
-
185
- registry . set ( 'test.shippingAddress.shipping-address-fieldset.country_id' , country ) ;
186
- registry . set ( 'checkout.errors' , { } ) ;
187
187
obj . source = {
188
188
get : jasmine . createSpy ( ) . and . returnValue ( true ) ,
189
189
set : jasmine . createSpy ( ) ,
@@ -199,20 +199,10 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
199
199
expect ( obj . validateShippingInformation ( ) ) . toBeFalsy ( ) ;
200
200
} ) ;
201
201
it ( 'Check method call on positive case.' , function ( ) {
202
- /* jscs:disable */
203
- var country = {
204
- on : function ( ) { } ,
205
- get : function ( ) { } ,
206
- set : function ( ) { }
207
- } ;
208
- /* jscs:enable */
209
-
210
202
$ ( 'body' ) . append ( '<form data-role="email-with-possible-login">' +
211
203
'<input type="text" name="username" />' +
212
204
'</form>' ) ;
213
205
214
- registry . set ( 'test.shippingAddress.shipping-address-fieldset.country_id' , country ) ;
215
- registry . set ( 'checkout.errors' , { } ) ;
216
206
obj . source = {
217
207
get : jasmine . createSpy ( ) . and . returnValue ( true ) ,
218
208
set : jasmine . createSpy ( ) ,
0 commit comments