Skip to content

Commit b398206

Browse files
committed
Cover changes with jasmine tests
1 parent b2fc304 commit b398206

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.test.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@
66
define([
77
'jquery',
88
'Magento_Wishlist/js/add-to-wishlist'
9-
], function ($) {
9+
], function ($, Widget) {
1010
'use strict';
1111

1212
describe('Testing addToWishlist widget', function () {
13-
var wdContainer;
13+
var wdContainer,
14+
wishlistWidget,
15+
eventMock = {
16+
preventDefault: jasmine.createSpy(),
17+
stopPropagation: jasmine.createSpy()
18+
};
1419

1520
beforeEach(function () {
1621
wdContainer = $('<input type="hidden" class="bundle-option-11 product bundle option" \n' +
1722
'name="bundle_option[11]" value="15" aria-required="true"/>');
23+
wishlistWidget = new Widget();
24+
$.fn.validation = {};
1825
});
1926

2027
afterEach(function () {
@@ -31,5 +38,15 @@ define([
3138
});
3239
expect(wdContainer.addToWishlist('option', 'bundleInfo')).toBe('test');
3340
});
41+
42+
it('verify update wichlist with validate product qty, valid qty', function () {
43+
var validation = spyOn($.fn, 'validation').and.returnValue(false);
44+
45+
wishlistWidget._validateWishlistQty(eventMock);
46+
expect(validation).toHaveBeenCalled();
47+
expect(eventMock.preventDefault).toHaveBeenCalled();
48+
expect(eventMock.stopPropagation).toHaveBeenCalled();
49+
});
50+
3451
});
3552
});

0 commit comments

Comments
 (0)