File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed
app/code/Magento/Swatches/view/base/web/js
dev/tests/js/jasmine/tests/app/code/Magento/Swatches/view/frontend/web/js Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -759,7 +759,7 @@ define([
759
759
760
760
$ ( document ) . trigger ( 'updateMsrpPriceBlock' ,
761
761
[
762
- _ . findKey ( $widget . options . jsonConfig . index , $widget . options . jsonConfig . defaultValues ) ,
762
+ this . _getSelectedOptionPriceIndex ( ) ,
763
763
$widget . options . jsonConfig . optionPrices
764
764
] ) ;
765
765
@@ -770,6 +770,22 @@ define([
770
770
$input . trigger ( 'change' ) ;
771
771
} ,
772
772
773
+ /**
774
+ * Get selected option price index
775
+ *
776
+ * @return {String|undefined }
777
+ * @private
778
+ */
779
+ _getSelectedOptionPriceIndex : function ( ) {
780
+ var allowedProduct = this . _getAllowedProductWithMinPrice ( this . _CalcProducts ( ) ) ;
781
+
782
+ if ( _ . isEmpty ( allowedProduct ) ) {
783
+ return undefined ;
784
+ }
785
+
786
+ return allowedProduct ;
787
+ } ,
788
+
773
789
/**
774
790
* Get human readable attribute code (eg. size, color) by it ID from configuration
775
791
*
Original file line number Diff line number Diff line change @@ -98,5 +98,37 @@ define([
98
98
widget . _UpdatePrice ( ) ;
99
99
expect ( productPriceMock . find ( ) . find . calls . count ( ) ) . toBe ( 1 ) ;
100
100
} ) ;
101
+
102
+ it ( 'check getSelectedOptionPriceIndex' , function ( ) {
103
+ var optionMock = '<div class="swatch-attribute" attribute-id="2" option-selected="4"></div>' ,
104
+ element = $ ( '<div class="' + widget . options . tooltipClass +
105
+ '"><div class="image"></div><div class="title"></div><div class="corner"></div>' +
106
+ optionMock + '</div>'
107
+ ) ,
108
+ optionPricesMock = {
109
+ optionPrices : {
110
+ p : {
111
+ finalPrice : {
112
+ amount : 12
113
+ }
114
+ }
115
+ }
116
+ } ;
117
+
118
+ widget . element = element ;
119
+ widget . options . classes . attributeClass = 'swatch-attribute' ;
120
+ widget . options . jsonConfig = optionPricesMock ;
121
+ widget . optionsMap = {
122
+ 2 : {
123
+ 4 : {
124
+ products : 'p'
125
+ } ,
126
+ hasOwnProperty : jasmine . createSpy ( ) . and . returnValue ( true )
127
+ } ,
128
+ hasOwnProperty : jasmine . createSpy ( ) . and . returnValue ( true )
129
+ } ;
130
+
131
+ expect ( widget . _getSelectedOptionPriceIndex ( ) ) . toBe ( 'p' ) ;
132
+ } ) ;
101
133
} ) ;
102
134
} ) ;
You can’t perform that action at this time.
0 commit comments