Skip to content

Commit 9ee47a9

Browse files
committed
MC-41165: Error on shipping step during checkout
1 parent 1018200 commit 9ee47a9

File tree

1 file changed

+19
-2
lines changed
  • dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/form/element

1 file changed

+19
-2
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/form/element/email.test.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/* eslint max-nested-callbacks: 0 */
77

8-
define(['squire', 'ko'], function (Squire, ko) {
8+
define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
99
'use strict';
1010

1111
describe('Magento_Checkout/js/view/form/element/email', function () {
@@ -32,11 +32,11 @@ define(['squire', 'ko'], function (Squire, ko) {
3232
]
3333
),
3434
'Magento_Checkout/js/model/full-screen-loader': jasmine.createSpy(),
35-
'mage/validation': jasmine.createSpy()
3635
},
3736
Component;
3837

3938
beforeEach(function (done) {
39+
window.checkoutConfig = {};
4040
injector.mock(mocks);
4141
injector.require(['Magento_Checkout/js/view/form/element/email'], function (Constr) {
4242
Component = new Constr({
@@ -62,5 +62,22 @@ define(['squire', 'ko'], function (Squire, ko) {
6262
expect(typeof Component.resolveInitialPasswordVisibility()).toEqual('boolean');
6363
});
6464
});
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+
});
6582
});
6683
});

0 commit comments

Comments
 (0)