@@ -12,14 +12,24 @@ require.config({
1212 }
1313} ) ;
1414
15- define ( [ 'squire' , 'ko' , 'jquery' , 'uiRegistry' , ' jquery/validate'] , function ( Squire , ko , $ , registry ) {
15+ define ( [ 'squire' , 'ko' , 'jquery' , 'jquery/validate' ] , function ( Squire , ko , $ ) {
1616 'use strict' ;
1717
1818 var injector = new Squire ( ) ,
1919 modalStub = {
2020 openModal : jasmine . createSpy ( ) ,
2121 closeModal : jasmine . createSpy ( )
2222 } ,
23+ country = {
24+ /** Stub */
25+ on : function ( ) { } ,
26+
27+ /** Stub */
28+ get : function ( ) { } ,
29+
30+ /** Stub */
31+ set : function ( ) { }
32+ } ,
2333 mocks = {
2434 'Magento_Customer/js/model/customer' : {
2535 isLoggedIn : ko . observable ( )
@@ -28,17 +38,7 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
2838 'Magento_Checkout/js/model/address-converter' : jasmine . createSpy ( ) ,
2939 'Magento_Checkout/js/model/quote' : {
3040 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 ( )
4242 } ,
4343 'Magento_Checkout/js/action/create-shipping-address' : jasmine . createSpy ( ) . and . returnValue (
4444 jasmine . createSpyObj ( 'newShippingAddress' , [ 'getKey' ] )
@@ -62,7 +62,18 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
6262 'checkoutData' ,
6363 [ 'setSelectedShippingAddress' , 'setNewCustomerShippingAddress' , 'setSelectedShippingRate' ]
6464 ) ,
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+ } ,
6677 'Magento_Checkout/js/model/shipping-rate-service' : jasmine . createSpy ( )
6778 } ,
6879 obj ;
@@ -73,7 +84,6 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
7384 obj = new Constr ( {
7485 provider : 'provName' ,
7586 name : '' ,
76- parentName : 'test' ,
7787 index : '' ,
7888 popUpForm : {
7989 options : {
@@ -174,16 +184,6 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
174184
175185 describe ( '"validateShippingInformation" method' , function ( ) {
176186 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' , { } ) ;
187187 obj . source = {
188188 get : jasmine . createSpy ( ) . and . returnValue ( true ) ,
189189 set : jasmine . createSpy ( ) ,
@@ -199,20 +199,10 @@ define(['squire', 'ko', 'jquery', 'uiRegistry', 'jquery/validate'], function (Sq
199199 expect ( obj . validateShippingInformation ( ) ) . toBeFalsy ( ) ;
200200 } ) ;
201201 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-
210202 $ ( 'body' ) . append ( '<form data-role="email-with-possible-login">' +
211203 '<input type="text" name="username" />' +
212204 '</form>' ) ;
213205
214- registry . set ( 'test.shippingAddress.shipping-address-fieldset.country_id' , country ) ;
215- registry . set ( 'checkout.errors' , { } ) ;
216206 obj . source = {
217207 get : jasmine . createSpy ( ) . and . returnValue ( true ) ,
218208 set : jasmine . createSpy ( ) ,
0 commit comments