@@ -255,6 +255,25 @@ describe('Render Product HTML', () => {
255
255
assert . strictEqual ( variantAttributesTable , null , 'Variant attributes table should not be rendered' ) ;
256
256
} ) ;
257
257
258
+ it ( 'should filter variant attributes if variantAttributes is set' , ( ) => {
259
+ config . variantAttributes = [ 'criteria_1' , 'criteria_2' ] ;
260
+ const html = htmlTemplateFromContext ( DEFAULT_CONTEXT ( { config } ) , product , variations ) . render ( ) ;
261
+ dom = new JSDOM ( html ) ;
262
+ document = dom . window . document ;
263
+ const variantAttributesTable = document . querySelector ( '.variant-attributes' ) ;
264
+ const variantAttributes = variantAttributesTable . querySelectorAll ( '.variant-attributes > div' ) ;
265
+ assert . strictEqual ( variantAttributes . length , 9 , 'Variant attributes table should be rendered with 2 attributes' ) ;
266
+ assert . strictEqual ( variantAttributes [ 0 ] . querySelector ( 'div:nth-child(1)' ) . textContent , 'sku' , 'Sku should be rendered' ) ;
267
+ assert . strictEqual ( variantAttributes [ 1 ] . querySelector ( 'div:nth-child(2)' ) . textContent , 'criteria_1' , 'Variant attribute 1 should be rendered' ) ;
268
+ assert . strictEqual ( variantAttributes [ 2 ] . querySelector ( 'div:nth-child(2)' ) . textContent , 'criteria_2' , 'Variant attribute 2 should be rendered' ) ;
269
+ assert . strictEqual ( variantAttributes [ 3 ] . querySelector ( 'div:nth-child(1)' ) . textContent , 'sku' , 'Sku should not be rendered' ) ;
270
+ assert . strictEqual ( variantAttributes [ 4 ] . querySelector ( 'div:nth-child(2)' ) . textContent , 'criteria_1' , 'Variant attribute 4 should not be rendered' ) ;
271
+ assert . strictEqual ( variantAttributes [ 5 ] . querySelector ( 'div:nth-child(2)' ) . textContent , 'criteria_2' , 'Variant attribute 5 should not be rendered' ) ;
272
+ assert . strictEqual ( variantAttributes [ 6 ] . querySelector ( 'div:nth-child(1)' ) . textContent , 'sku' , 'Sku should not be rendered' ) ;
273
+ assert . strictEqual ( variantAttributes [ 7 ] . querySelector ( 'div:nth-child(2)' ) . textContent , 'criteria_1' , 'Variant attribute 4 should not be rendered' ) ;
274
+ assert . strictEqual ( variantAttributes [ 8 ] . querySelector ( 'div:nth-child(2)' ) . textContent , 'criteria_2' , 'Variant attribute 5 should not be rendered' ) ;
275
+ } ) ;
276
+
258
277
it ( 'template should allow for missing prices' , ( ) => {
259
278
config . confMap = {
260
279
'/us/p/{{urlkey}}/{{sku}}' : { } ,
0 commit comments