Skip to content

Commit de85752

Browse files
committed
MC-29938: Price of a Bundle Product is calculated incorrectly at the product page
- add js unit test
1 parent d5eaee5 commit de85752

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'Magento_Bundle/js/price-bundle',
9+
'Magento_Catalog/js/price-box'
10+
], function ($) {
11+
'use strict';
12+
13+
describe('Magento_Bundle/js/price-bundle', function () {
14+
15+
var htmlContainer;
16+
17+
beforeEach(function () {
18+
htmlContainer = $('<div class="price-final_price" data-role="priceBox"><ul class="price-box"></ul></div>');
19+
});
20+
21+
afterEach(function () {
22+
htmlContainer.remove();
23+
});
24+
25+
it('Widget extends jQuery object.', function () {
26+
expect($.fn.priceBundle).toBeDefined();
27+
});
28+
29+
it('Check _updatePriceBox method call.', function () {
30+
31+
spyOn($.mage.priceBundle.prototype, '_updatePriceBox');
32+
33+
htmlContainer.priceBundle();
34+
35+
expect($.mage.priceBundle.prototype._updatePriceBox).toEqual(jasmine.any(Function));
36+
expect($.mage.priceBundle.prototype._updatePriceBox).toHaveBeenCalled();
37+
expect($.mage.priceBundle.prototype._updatePriceBox).toHaveBeenCalledTimes(1);
38+
});
39+
40+
it('Check _updatePriceBox method call after priceBox was initialized.', function () {
41+
spyOn($.mage.priceBundle.prototype, '_updatePriceBox').and.callThrough();
42+
htmlContainer.priceBundle();
43+
$('.price-box', htmlContainer).priceBox();
44+
expect($.mage.priceBundle.prototype._updatePriceBox).toEqual(jasmine.any(Function));
45+
expect($.mage.priceBundle.prototype._updatePriceBox).toHaveBeenCalledTimes(2);
46+
});
47+
48+
it('Check _updatePriceBox method call before priceBox was initialized.', function () {
49+
spyOn($.mage.priceBundle.prototype, '_updatePriceBox').and.callThrough();
50+
$('.price-box', htmlContainer).priceBox();
51+
htmlContainer.priceBundle();
52+
expect($.mage.priceBundle.prototype._updatePriceBox).toEqual(jasmine.any(Function));
53+
expect($.mage.priceBundle.prototype._updatePriceBox).toHaveBeenCalledTimes(1);
54+
});
55+
});
56+
});

0 commit comments

Comments
 (0)