@@ -67,8 +67,14 @@ define([
6767 'salable' : [ ]
6868 }
6969 } ,
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]\'' +
7278 ' data-selector=\'super_attribute[93]\'' +
7379 ' data-validate=\'{required:true}\'' +
7480 ' id=\'attribute93\'' +
@@ -78,7 +84,9 @@ define([
7884 '<option value=\'15\'>beige</option>' +
7985 '</select>' +
8086 '<input id="qty"/>' +
81- '</form>' ,
87+ '</form>' +
88+ '</div>' +
89+ '</div>' ,
8290 selectElement ,
8391 qtyElement ,
8492 formElement ;
@@ -89,13 +97,22 @@ define([
8997 selectElement = $ ( '#attribute93' ) ;
9098 qtyElement = $ ( '#qty' ) ;
9199 formElement = $ ( '#cart' ) ;
92- widget = new Configurable ( $ . extend ( true , { } , options ) , formElement ) ;
93100 $ . 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 ) ;
94109 } ) ;
95110 afterEach ( function ( ) {
96111 formElement . remove ( ) ;
97112 $ . fn . trigger = $ . fn . trigFunc ;
113+ $ . fn . priceBox = $ . fn . priceBoxFunc ;
98114 delete $ . fn . trigFunc ;
115+ delete $ . fn . priceBoxFunc ;
99116 } ) ;
100117 it ( 'check if attribute value is possible to be set as configurable option' , function ( ) {
101118 expect ( $ . mage . configurable ) . toBeDefined ( ) ;
@@ -112,17 +129,6 @@ define([
112129 it ( 'check if widget will return correct price values in case option is selected or not.' , function ( ) {
113130 var result ;
114131
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- } ) ;
126132 result = widget . _getPrices ( ) . prices ;
127133 expect ( result . baseOldPrice . amount ) . toBe ( 0 ) ;
128134 expect ( result . oldPrice . amount ) . toBe ( 0 ) ;
@@ -140,7 +146,26 @@ define([
140146 it ( 'check that price is reloaded on qty change' , function ( ) {
141147 spyOn ( $ . fn , 'trigger' ) ;
142148 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+ ) ;
144169 } ) ;
145170
146171 it ( 'check if the _configureElement method is enabling configurable option or not' , function ( ) {
0 commit comments