5
5
6
6
/* eslint max-nested-callbacks: 0 */
7
7
8
- define ( [ 'squire' , 'ko' ] , function ( Squire , ko ) {
8
+ define ( [ 'squire' , 'ko' , 'jquery' , 'jquery/validate' ] , function ( Squire , ko , $ ) {
9
9
'use strict' ;
10
10
11
11
describe ( 'Magento_Checkout/js/view/form/element/email' , function ( ) {
@@ -32,11 +32,11 @@ define(['squire', 'ko'], function (Squire, ko) {
32
32
]
33
33
) ,
34
34
'Magento_Checkout/js/model/full-screen-loader' : jasmine . createSpy ( ) ,
35
- 'mage/validation' : jasmine . createSpy ( )
36
35
} ,
37
36
Component ;
38
37
39
38
beforeEach ( function ( done ) {
39
+ window . checkoutConfig = { } ;
40
40
injector . mock ( mocks ) ;
41
41
injector . require ( [ 'Magento_Checkout/js/view/form/element/email' ] , function ( Constr ) {
42
42
Component = new Constr ( {
@@ -62,5 +62,22 @@ define(['squire', 'ko'], function (Squire, ko) {
62
62
expect ( typeof Component . resolveInitialPasswordVisibility ( ) ) . toEqual ( 'boolean' ) ;
63
63
} ) ;
64
64
} ) ;
65
+
66
+ describe ( '"validateEmail" method' , function ( ) {
67
+ beforeEach ( function ( ) {
68
+ $ ( 'body' ) . append ( '<form data-role="email-with-possible-login">' +
69
+ '<input type="text" name="username" />' +
70
+ '</form>' ) ;
71
+ spyOn ( $ . fn , 'validate' ) . and . returnValue ( true ) ;
72
+ } ) ;
73
+ it ( 'Check if login form will be validated in case it is not visible' , function ( ) {
74
+ var loginFormSelector = 'form[data-role=email-with-possible-login]' ,
75
+ loginForm = $ ( loginFormSelector ) ;
76
+ loginForm . hide ( ) ;
77
+ Component . validateEmail ( ) ;
78
+ expect ( loginForm . is ( ':visible' ) ) . toBeFalsy ( ) ;
79
+ expect ( loginForm . validate ) . not . toHaveBeenCalled ( ) ;
80
+ } ) ;
81
+ } ) ;
65
82
} ) ;
66
83
} ) ;
0 commit comments