-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5187 from magento-trigger/MC-30257
-fixed Price of a Bundle Product is calculated incorrectly at the product page
- Loading branch information
Showing
3 changed files
with
104 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
dev/tests/js/jasmine/tests/app/code/Magento/Bundle/base/js/price-bundle.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'jquery', | ||
'Magento_Bundle/js/price-bundle', | ||
'Magento_Catalog/js/price-box' | ||
], function ($) { | ||
'use strict'; | ||
|
||
describe('Magento_Bundle/js/price-bundle', function () { | ||
|
||
var htmlContainer; | ||
|
||
beforeEach(function () { | ||
htmlContainer = $('<div class="price-final_price" data-role="priceBox"><ul class="price-box"></ul></div>'); | ||
}); | ||
|
||
afterEach(function () { | ||
htmlContainer.remove(); | ||
}); | ||
|
||
it('Widget extends jQuery object.', function () { | ||
expect($.fn.priceBundle).toBeDefined(); | ||
}); | ||
|
||
it('Check _updatePriceBox method call.', function () { | ||
|
||
spyOn($.mage.priceBundle.prototype, '_updatePriceBox'); | ||
|
||
htmlContainer.priceBundle(); | ||
|
||
expect($.mage.priceBundle.prototype._updatePriceBox).toEqual(jasmine.any(Function)); | ||
expect($.mage.priceBundle.prototype._updatePriceBox).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('Check _updatePriceBox method call after priceBox was initialized.', function () { | ||
spyOn($.mage.priceBundle.prototype, '_updatePriceBox').and.callThrough(); | ||
htmlContainer.priceBundle(); | ||
$('.price-box', htmlContainer).priceBox(); | ||
expect($.mage.priceBundle.prototype._updatePriceBox).toEqual(jasmine.any(Function)); | ||
expect($.mage.priceBundle.prototype._updatePriceBox).toHaveBeenCalledTimes(2); | ||
}); | ||
|
||
it('Check _applyOptionNodeFix method doesn\'t call after priceBox initialization.', function () { | ||
var optionConfig = { | ||
optionConfig: { | ||
prices: {} | ||
} | ||
}, | ||
priceConfig = { | ||
priceConfig: 10 | ||
}; | ||
|
||
spyOn($.mage.priceBundle.prototype, '_applyOptionNodeFix').and.callThrough(); | ||
htmlContainer.priceBundle(optionConfig); | ||
$('.price-box', htmlContainer).priceBox(priceConfig); | ||
$('.price-box', htmlContainer).trigger('price-box-initialized'); | ||
expect($.mage.priceBundle.prototype._applyOptionNodeFix).toEqual(jasmine.any(Function)); | ||
expect($.mage.priceBundle.prototype._applyOptionNodeFix).toHaveBeenCalledTimes(2); | ||
}); | ||
|
||
it('Check _updatePriceBox method call before priceBox was initialized.', function () { | ||
spyOn($.mage.priceBundle.prototype, '_updatePriceBox').and.callThrough(); | ||
$('.price-box', htmlContainer).priceBox(); | ||
htmlContainer.priceBundle(); | ||
expect($.mage.priceBundle.prototype._updatePriceBox).toEqual(jasmine.any(Function)); | ||
expect($.mage.priceBundle.prototype._updatePriceBox).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
}); |