@@ -495,6 +495,61 @@ test('getFacetValues(hierarchical) takes `rootPath` into account', function () {
495
495
expect ( facetValues ) . toEqual ( expected ) ;
496
496
} ) ;
497
497
498
+ test ( 'getFacetValues(hierarchical) correctly sets `isRefined` on facet values with trailing spaces' , function ( ) {
499
+ var searchParams = new SearchParameters ( {
500
+ index : 'instant_search' ,
501
+ hierarchicalFacets : [
502
+ {
503
+ name : 'type' ,
504
+ attributes : [ 'type1' , 'type2' , 'type3' ] ,
505
+ } ,
506
+ ] ,
507
+ hierarchicalFacetsRefinements : { type : [ 'something > discounts ' ] } ,
508
+ } ) ;
509
+
510
+ var result = {
511
+ query : '' ,
512
+ facets : {
513
+ type1 : {
514
+ dogs : 1 ,
515
+ something : 5 ,
516
+ } ,
517
+ type2 : {
518
+ 'dogs > hounds' : 1 ,
519
+ 'something > discounts ' : 5 ,
520
+ } ,
521
+ type3 : {
522
+ 'something > discounts > -5%' : 1 ,
523
+ 'something > discounts > full price' : 4 ,
524
+ } ,
525
+ } ,
526
+ exhaustiveFacetsCount : true ,
527
+ } ;
528
+
529
+ var results = new SearchResults ( searchParams , [ result , result , result ] ) ;
530
+
531
+ var facetValues = results . getFacetValues ( 'type' ) ;
532
+
533
+ expect ( facetValues ) . toEqual (
534
+ expect . objectContaining ( {
535
+ name : 'type' ,
536
+ isRefined : true ,
537
+ data : expect . arrayContaining ( [
538
+ expect . objectContaining ( {
539
+ name : 'something' ,
540
+ isRefined : true ,
541
+ data : expect . arrayContaining ( [
542
+ expect . objectContaining ( {
543
+ name : 'discounts' ,
544
+ isRefined : true ,
545
+ } ) ,
546
+ ] ) ,
547
+ } ) ,
548
+ ] ) ,
549
+ } )
550
+ ) ;
551
+ } ) ;
552
+
498
553
test ( 'getFacetValues(unknown) returns undefined (does not throw)' , function ( ) {
499
554
var searchParams = new SearchParameters ( {
500
555
index : 'instant_search' ,
0 commit comments