@@ -67,8 +67,14 @@ define([
67
67
'salable' : [ ]
68
68
}
69
69
} ,
70
- blockHtml = '<form id="cart"/>'
71
- + '<select name=\'super_attribute[93]\'' +
70
+ blockHtml = '<div class="product-info-main">' +
71
+ '<div class="product-info-price">' +
72
+ '<div class="price-box price-final_price" data-role="priceBox">' +
73
+ '</div>' +
74
+ '</div>' +
75
+ '<div class="product-add-form">' +
76
+ '<form id="cart"/>' +
77
+ '<select name=\'super_attribute[93]\'' +
72
78
' data-selector=\'super_attribute[93]\'' +
73
79
' data-validate=\'{required:true}\'' +
74
80
' id=\'attribute93\'' +
@@ -78,7 +84,9 @@ define([
78
84
'<option value=\'15\'>beige</option>' +
79
85
'</select>' +
80
86
'<input id="qty"/>' +
81
- '</form>' ,
87
+ '</form>' +
88
+ '</div>' +
89
+ '</div>' ,
82
90
selectElement ,
83
91
qtyElement ,
84
92
formElement ;
@@ -89,13 +97,22 @@ define([
89
97
selectElement = $ ( '#attribute93' ) ;
90
98
qtyElement = $ ( '#qty' ) ;
91
99
formElement = $ ( '#cart' ) ;
92
- widget = new Configurable ( $ . extend ( true , { } , options ) , formElement ) ;
93
100
$ . fn . trigFunc = $ . fn . trigger ;
101
+ $ . fn . priceBoxFunc = $ . fn . priceBox ;
102
+ $ . fn . priceBox = function ( ) {
103
+ return {
104
+ prices : $ . extend ( true , { } , this . data ( 'price-box' ) )
105
+ } ;
106
+ } ;
107
+ $ ( 'body' ) . find ( '[data-role=priceBox]' ) . data ( 'price-box' , $ . extend ( true , { } , options . spConfig . prices ) ) ;
108
+ widget = new Configurable ( $ . extend ( true , { } , options ) , formElement ) ;
94
109
} ) ;
95
110
afterEach ( function ( ) {
96
111
formElement . remove ( ) ;
97
112
$ . fn . trigger = $ . fn . trigFunc ;
113
+ $ . fn . priceBox = $ . fn . priceBoxFunc ;
98
114
delete $ . fn . trigFunc ;
115
+ delete $ . fn . priceBoxFunc ;
99
116
} ) ;
100
117
it ( 'check if attribute value is possible to be set as configurable option' , function ( ) {
101
118
expect ( $ . mage . configurable ) . toBeDefined ( ) ;
@@ -112,17 +129,6 @@ define([
112
129
it ( 'check if widget will return correct price values in case option is selected or not.' , function ( ) {
113
130
var result ;
114
131
115
- spyOn ( $ . fn , 'priceBox' ) . and . callFake ( function ( ) {
116
- return {
117
- prices : {
118
- 'baseOldPrice' : { 'amount' : 10 } ,
119
- 'oldPrice' : { 'amount' : 10 } ,
120
- 'basePrice' : { 'amount' : 10 } ,
121
- 'finalPrice' : { 'amount' : 10 } ,
122
- 'msrpPrice' : { 'amount' : 0 }
123
- }
124
- } ;
125
- } ) ;
126
132
result = widget . _getPrices ( ) . prices ;
127
133
expect ( result . baseOldPrice . amount ) . toBe ( 0 ) ;
128
134
expect ( result . oldPrice . amount ) . toBe ( 0 ) ;
@@ -140,7 +146,26 @@ define([
140
146
it ( 'check that price is reloaded on qty change' , function ( ) {
141
147
spyOn ( $ . fn , 'trigger' ) ;
142
148
qtyElement . trigFunc ( 'input' ) ;
143
- expect ( $ . fn . trigger ) . toHaveBeenCalledWith ( 'updatePrice' , { } ) ;
149
+ expect ( $ . fn . trigger )
150
+ . toHaveBeenCalledWith (
151
+ 'updatePrice' ,
152
+ {
153
+ prices : {
154
+ baseOldPrice : {
155
+ amount : 0
156
+ } ,
157
+ oldPrice : {
158
+ amount : 0
159
+ } ,
160
+ basePrice : {
161
+ amount : 0
162
+ } ,
163
+ finalPrice : {
164
+ amount : 0
165
+ }
166
+ }
167
+ }
168
+ ) ;
144
169
} ) ;
145
170
146
171
it ( 'check if the _configureElement method is enabling configurable option or not' , function ( ) {
0 commit comments