@@ -57,6 +57,18 @@ describe('PoPageDynamicSearchComponent:', () => {
57
57
expect ( component . filterSettings . width ) . toBe ( filterWidth ) ;
58
58
} ) ;
59
59
60
+ it ( 'get disclaimerGroup: should apply `hideRemoveAll` value to false by default' , ( ) => {
61
+ const disclaimerGroup = component . disclaimerGroup ;
62
+
63
+ expect ( disclaimerGroup . hideRemoveAll ) . toBeFalse ( ) ;
64
+ } ) ;
65
+ it ( 'get disclaimerGroup: should apply `hideRemoveAll` value to true when property `hideRemoveAllDisclaimer` is true' , ( ) => {
66
+ component . hideRemoveAllDisclaimer = true ;
67
+ const disclaimerGroup = component . disclaimerGroup ;
68
+
69
+ expect ( disclaimerGroup . hideRemoveAll ) . toBeTrue ( ) ;
70
+ } ) ;
71
+
60
72
describe ( 'onAction:' , ( ) => {
61
73
let fakethis ;
62
74
@@ -74,7 +86,8 @@ describe('PoPageDynamicSearchComponent:', () => {
74
86
} ,
75
87
literals : {
76
88
quickSearchLabel : 'Pesquisa rápida:'
77
- }
89
+ } ,
90
+ hideCloseDisclaimers : [ ]
78
91
} ;
79
92
} ) ;
80
93
@@ -96,9 +109,35 @@ describe('PoPageDynamicSearchComponent:', () => {
96
109
expect ( fakethis . quickSearch . emit ) . not . toHaveBeenCalled ( ) ;
97
110
} ) ;
98
111
99
- it ( 'should set `_dislaimerGroup.disclaimers` with property, label and value' , ( ) => {
100
- const result = [ { property : 'search' , label : 'Pesquisa rápida: quickFilter' , value : 'quickFilter' } ] ;
112
+ it ( 'should set `_dislaimerGroup.disclaimers` with property, label, value and hideClose' , ( ) => {
113
+ const result = [
114
+ { property : 'search' , label : 'Pesquisa rápida: quickFilter' , value : 'quickFilter' , hideClose : false }
115
+ ] ;
116
+
117
+ component . onAction . call ( fakethis , 'quickFilter' ) ;
118
+
119
+ expect ( fakethis . _disclaimerGroup . disclaimers ) . toEqual ( result ) ;
120
+ } ) ;
121
+
122
+ it ( `should set '_dislaimerGroup.disclaimers' with 'hideClose: true' when property is
123
+ included on the 'hideCloseDisclaimers'` , ( ) => {
124
+ const result = [
125
+ { property : 'search' , label : 'Pesquisa rápida: quickFilter' , value : 'quickFilter' , hideClose : true }
126
+ ] ;
127
+
128
+ fakethis [ 'hideCloseDisclaimers' ] = [ 'search' ] ;
129
+ component . onAction . call ( fakethis , 'quickFilter' ) ;
130
+
131
+ expect ( fakethis . _disclaimerGroup . disclaimers ) . toEqual ( result ) ;
132
+ } ) ;
133
+
134
+ it ( `should set '_dislaimerGroup.disclaimers' with 'hideClose: false' when property is not
135
+ included on the 'hideCloseDisclaimers'` , ( ) => {
136
+ const result = [
137
+ { property : 'search' , label : 'Pesquisa rápida: quickFilter' , value : 'quickFilter' , hideClose : false }
138
+ ] ;
101
139
140
+ fakethis [ 'hideCloseDisclaimers' ] = [ 'name' ] ;
102
141
component . onAction . call ( fakethis , 'quickFilter' ) ;
103
142
104
143
expect ( fakethis . _disclaimerGroup . disclaimers ) . toEqual ( result ) ;
@@ -276,9 +315,9 @@ describe('PoPageDynamicSearchComponent:', () => {
276
315
const filters = { name : 'Roger' , birthdate : '2018-12-12T00:00:01-00:00' , genre : 'male' } ;
277
316
278
317
const result = [
279
- { label : 'Name: Roger' , property : 'name' , value : 'Roger' } ,
280
- { label : 'Birthdate: 12/12/2018' , property : 'birthdate' , value : '2018-12-12T00:00:01-00:00' } ,
281
- { label : 'Genre: male' , property : 'genre' , value : 'male' }
318
+ { label : 'Name: Roger' , property : 'name' , value : 'Roger' , hideClose : false } ,
319
+ { label : 'Birthdate: 12/12/2018' , property : 'birthdate' , value : '2018-12-12T00:00:01-00:00' , hideClose : false } ,
320
+ { label : 'Genre: male' , property : 'genre' , value : 'male' , hideClose : false }
282
321
] ;
283
322
284
323
spyOn ( component , < any > 'getFieldByProperty' ) . and . callThrough ( ) ;
@@ -299,8 +338,8 @@ describe('PoPageDynamicSearchComponent:', () => {
299
338
const filters = { name : 'Name1' , genre : 'male' } ;
300
339
301
340
const result = [
302
- { label : 'Name: Name1' , property : 'name' , value : 'Name1' } ,
303
- { label : 'Genre: male' , property : 'genre' , value : 'male' }
341
+ { label : 'Name: Name1' , property : 'name' , value : 'Name1' , hideClose : false } ,
342
+ { label : 'Genre: male' , property : 'genre' , value : 'male' , hideClose : false }
304
343
] ;
305
344
306
345
spyOn ( component , < any > 'getFieldByProperty' ) . and . callThrough ( ) ;
@@ -318,8 +357,8 @@ describe('PoPageDynamicSearchComponent:', () => {
318
357
const filters = { name : 'Name1' , genre : 'male' } ;
319
358
320
359
const result = [
321
- { label : 'Name: Name1' , property : 'name' , value : 'Name1' } ,
322
- { label : 'Genre: male' , property : 'genre' , value : 'male' }
360
+ { label : 'Name: Name1' , property : 'name' , value : 'Name1' , hideClose : false } ,
361
+ { label : 'Genre: male' , property : 'genre' , value : 'male' , hideClose : false }
323
362
] ;
324
363
325
364
expect ( component [ 'setDisclaimers' ] ( filters ) ) . toEqual ( result ) ;
@@ -334,7 +373,47 @@ describe('PoPageDynamicSearchComponent:', () => {
334
373
335
374
const filters = { name : 'Name1' , genre : 'male' } ;
336
375
337
- const result = [ { label : 'Name: Name1' , property : 'name' , value : 'Name1' } ] ;
376
+ const result = [ { label : 'Name: Name1' , property : 'name' , value : 'Name1' , hideClose : false } ] ;
377
+
378
+ expect ( component [ 'setDisclaimers' ] ( filters ) ) . toEqual ( result ) ;
379
+ } ) ;
380
+
381
+ it ( `setDisclaimers: should return disclaimers based on the 'filters' with the 'hideClose: true' to filters included on the 'hideCloseDisclaimers'` , ( ) => {
382
+ component . filters = [
383
+ { property : 'name' , label : 'Name' } ,
384
+ { property : 'birthdate' , label : 'Birthdate' , type : 'date' } ,
385
+ { property : 'genre' , label : 'Genre' }
386
+ ] ;
387
+
388
+ component . hideCloseDisclaimers = [ 'name' , 'birthdate' ] ;
389
+
390
+ const filters = { name : 'Roger' , birthdate : '2018-12-12T00:00:01-00:00' , genre : 'male' } ;
391
+
392
+ const result = [
393
+ { label : 'Name: Roger' , property : 'name' , value : 'Roger' , hideClose : true } ,
394
+ { label : 'Birthdate: 12/12/2018' , property : 'birthdate' , value : '2018-12-12T00:00:01-00:00' , hideClose : true } ,
395
+ { label : 'Genre: male' , property : 'genre' , value : 'male' , hideClose : false }
396
+ ] ;
397
+
398
+ expect ( component [ 'setDisclaimers' ] ( filters ) ) . toEqual ( result ) ;
399
+ } ) ;
400
+
401
+ it ( `setDisclaimers: should return disclaimers based on the 'filters' with the 'hideClose: false' to filters not included on the 'hideCloseDisclaimers'` , ( ) => {
402
+ component . filters = [
403
+ { property : 'name' , label : 'Name' } ,
404
+ { property : 'birthdate' , label : 'Birthdate' , type : 'date' } ,
405
+ { property : 'genre' , label : 'Genre' }
406
+ ] ;
407
+
408
+ component . hideCloseDisclaimers = [ 'test' ] ;
409
+
410
+ const filters = { name : 'Roger' , birthdate : '2018-12-12T00:00:01-00:00' , genre : 'male' } ;
411
+
412
+ const result = [
413
+ { label : 'Name: Roger' , property : 'name' , value : 'Roger' , hideClose : false } ,
414
+ { label : 'Birthdate: 12/12/2018' , property : 'birthdate' , value : '2018-12-12T00:00:01-00:00' , hideClose : false } ,
415
+ { label : 'Genre: male' , property : 'genre' , value : 'male' , hideClose : false }
416
+ ] ;
338
417
339
418
expect ( component [ 'setDisclaimers' ] ( filters ) ) . toEqual ( result ) ;
340
419
} ) ;
@@ -551,6 +630,7 @@ describe('PoPageDynamicSearchComponent:', () => {
551
630
component . filters = [ { property : 'filter1' } , { property : 'filter2' } ] ;
552
631
component . title = 'Original Title' ;
553
632
component . quickSearchWidth = 3 ;
633
+ component . hideCloseDisclaimers = [ 'filter1' ] ;
554
634
555
635
component . onLoad = ( ) => ( {
556
636
title : 'New Title' ,
@@ -563,7 +643,9 @@ describe('PoPageDynamicSearchComponent:', () => {
563
643
] ,
564
644
filters : [ { property : 'filter1' } , { property : 'filter3' } ] ,
565
645
keepFilters : true ,
566
- quickSearchWidth : 6
646
+ quickSearchWidth : 6 ,
647
+ hideRemoveAllDisclaimer : true ,
648
+ hideCloseDisclaimers : [ 'filter3' ]
567
649
} ) ;
568
650
569
651
component . ngOnInit ( ) ;
@@ -580,6 +662,8 @@ describe('PoPageDynamicSearchComponent:', () => {
580
662
} ) ;
581
663
expect ( component . keepFilters ) . toBeTrue ( ) ;
582
664
expect ( component . quickSearchWidth ) . toBe ( 6 ) ;
665
+ expect ( component . hideRemoveAllDisclaimer ) . toBeTrue ( ) ;
666
+ expect ( component . hideCloseDisclaimers ) . toEqual ( [ 'filter3' ] ) ;
583
667
} ) ) ;
584
668
} ) ;
585
669
} ) ;
@@ -605,8 +689,8 @@ describe('PoPageDynamicSearchComponent:', () => {
605
689
component . onAction ( 'Chicago' ) ;
606
690
607
691
const currentDisclaimers = [
608
- { label : 'City: Ontario' , value : 'Ontario' , property : 'city' } ,
609
- { property : 'search' , label : `Search Chicago` , value : 'Chicago' }
692
+ { label : 'City: Ontario' , value : 'Ontario' , property : 'city' , hideClose : false } ,
693
+ { property : 'search' , label : `Search Chicago` , value : 'Chicago' , hideClose : false }
610
694
] ;
611
695
612
696
expect ( component . disclaimerGroup . disclaimers ) . toEqual ( currentDisclaimers ) ;
@@ -623,8 +707,8 @@ describe('PoPageDynamicSearchComponent:', () => {
623
707
component . onAction ( 'Test' ) ;
624
708
625
709
const currentDisclaimers = [
626
- { label : 'City: Ontario' , value : 'Ontario' , property : 'city' } ,
627
- { property : 'search' , label : `Search Test` , value : 'Test' }
710
+ { label : 'City: Ontario' , value : 'Ontario' , property : 'city' , hideClose : false } ,
711
+ { property : 'search' , label : `Search Test` , value : 'Test' , hideClose : false }
628
712
] ;
629
713
630
714
expect ( component . disclaimerGroup . disclaimers ) . toEqual ( currentDisclaimers ) ;
@@ -635,11 +719,15 @@ describe('PoPageDynamicSearchComponent:', () => {
635
719
636
720
component . literals . quickSearchLabel = 'Search' ;
637
721
component . onAction ( 'Chicago' ) ;
638
- const disclaimersWithQuickFilter = [ { property : 'search' , label : `Search Chicago` , value : 'Chicago' } ] ;
722
+ const disclaimersWithQuickFilter = [
723
+ { property : 'search' , label : `Search Chicago` , value : 'Chicago' , hideClose : false }
724
+ ] ;
639
725
640
726
expect ( component . disclaimerGroup . disclaimers ) . toEqual ( disclaimersWithQuickFilter ) ;
641
727
642
- const disclaimersWithAdvancedSearch = [ { label : 'City: Ontario' , value : 'Ontario' , property : 'city' } ] ;
728
+ const disclaimersWithAdvancedSearch = [
729
+ { label : 'City: Ontario' , value : 'Ontario' , property : 'city' , hideClose : false }
730
+ ] ;
643
731
644
732
component . filters = [ { property : 'city' , initValue : 'Ontario' } ] ;
645
733
@@ -651,11 +739,15 @@ describe('PoPageDynamicSearchComponent:', () => {
651
739
652
740
component . literals . quickSearchLabel = 'Search' ;
653
741
component . onAction ( 'Chicago' ) ;
654
- const disclaimersWithQuickFilter = [ { property : 'search' , label : `Search Chicago` , value : 'Chicago' } ] ;
742
+ const disclaimersWithQuickFilter = [
743
+ { property : 'search' , label : `Search Chicago` , value : 'Chicago' , hideClose : false }
744
+ ] ;
655
745
656
746
expect ( component . disclaimerGroup . disclaimers ) . toEqual ( disclaimersWithQuickFilter ) ;
657
747
658
- const disclaimersWithAdvancedSearch = [ { label : 'City: Ontario' , value : 'Ontario' , property : 'city' } ] ;
748
+ const disclaimersWithAdvancedSearch = [
749
+ { label : 'City: Ontario' , value : 'Ontario' , property : 'city' , hideClose : false }
750
+ ] ;
659
751
660
752
component . filters = [ { property : 'city' , initValue : 'Ontario' } ] ;
661
753
0 commit comments