From e037d514215f9e662b5585a5ab967ca4edcde3af Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 26 Dec 2019 14:05:28 +0200 Subject: [PATCH] Fix static test, civer with jasmine test --- .../view/base/web/js/swatch-renderer.js | 2 +- .../frontend/web/js/swatch-renderer.test.js | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js index c80962a44d0dc..ee55beb440f59 100644 --- a/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js +++ b/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js @@ -952,7 +952,7 @@ define([ isShow = typeof result != 'undefined' && result.oldPrice.amount !== result.finalPrice.amount; - $productPrice.find('span:first').toggleClass('special-price',isShow); + $productPrice.find('span:first').toggleClass('special-price', isShow); $product.find(this.options.slyOldPriceSelector)[isShow ? 'show' : 'hide'](); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.test.js index bf0ff3466c529..f486123ba0bd3 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.test.js @@ -28,6 +28,7 @@ define([ id: optionId }] }; + widget.options = { classes: { optionClass: 'swatch-option' @@ -50,6 +51,7 @@ define([ } } }; + optionConfig = widget.options.jsonSwatchConfig[attribute.id]; html = $(widget._RenderSwatchOptions(attribute, 'option-label-control-id-1'))[0]; }); @@ -76,5 +78,25 @@ define([ expect(html.style.height).toEqual(swathImageHeight + 'px'); expect(html.style.width).toEqual(swathImageWidth + 'px'); }); + + it('check udate price method', function () { + var productPriceMock = { + find: jasmine.createSpy().and.returnValue({ + hide: jasmine.createSpy(), + priceBox: jasmine.createSpy().and.returnValue(''), + trigger: jasmine.createSpy(), + find: jasmine.createSpy().and.returnValue({ + toggleClass: jasmine.createSpy() + }) + }) + }; + + widget.element = { + parents: jasmine.createSpy().and.returnValue(productPriceMock) + }; + widget._getNewPrices = jasmine.createSpy().and.returnValue(undefined); + widget._UpdatePrice(); + expect(productPriceMock.find().find.calls.count()).toBe(1); + }); }); });