@@ -58,9 +58,14 @@ describe('Component: UiGrid', () => {
58
58
width="25%">
59
59
</ui-grid-column>
60
60
61
- <ui-grid-column [property]="'myObj.myObjString'"
61
+ <ui-grid-column *ngIf="isColumnVisible"
62
+ [property]="'myObj.myObjString'"
62
63
title="Nested String Header"
63
64
width="25%">
65
+ <ui-grid-dropdown-filter [items]="someFilter"
66
+ [showAllOption]="true"
67
+ method="ge">
68
+ </ui-grid-dropdown-filter>
64
69
</ui-grid-column>
65
70
66
71
<ui-grid-column [property]="'myObj.myObjDate'"
@@ -77,6 +82,8 @@ describe('Component: UiGrid', () => {
77
82
public grid ! : UiGridComponent < ITestEntity > ;
78
83
79
84
public data : ITestEntity [ ] = [ ] ;
85
+ public someFilter = [ ] ;
86
+ public isColumnVisible = true ;
80
87
public selectable ?: boolean ;
81
88
public refreshable ?: boolean ;
82
89
}
@@ -149,6 +156,22 @@ describe('Component: UiGrid', () => {
149
156
150
157
expect ( headerCells . length ) . toEqual ( 0 ) ;
151
158
} ) ;
159
+
160
+ it ( 'should hide the ngIf-ed column and its filter' , ( ) => {
161
+ let headers = fixture . debugElement . queryAll ( By . css ( '.ui-grid-header-cell' ) ) ;
162
+ const getDropdownFilter = ( ) => fixture . debugElement . query ( By . css ( '.ui-grid-dropdown-filter-container' ) ) ;
163
+
164
+ expect ( headers ) . toBeDefined ( ) ;
165
+ expect ( headers . length ) . toEqual ( 4 ) ;
166
+ expect ( getDropdownFilter ( ) ) . toBeTruthy ( ) ;
167
+
168
+ fixture . componentInstance . isColumnVisible = false ;
169
+ fixture . detectChanges ( ) ;
170
+
171
+ headers = fixture . debugElement . queryAll ( By . css ( '.ui-grid-header-cell' ) ) ;
172
+ expect ( headers . length ) . toEqual ( 3 ) ;
173
+ expect ( getDropdownFilter ( ) ) . toBeFalsy ( ) ;
174
+ } ) ;
152
175
} ) ;
153
176
154
177
describe ( 'State: populated' , ( ) => {
@@ -1063,32 +1086,9 @@ describe('Component: UiGrid', () => {
1063
1086
SORT_TRANSITIONS . forEach ( sortTransition => {
1064
1087
it ( `should emit sort event when clicked ('${
1065
1088
sortTransition . from } ' to '${ sortTransition . to } ')`, ( done ) => {
1066
- const sortableHeader = fixture . debugElement . query ( By . css ( '.ui-grid-header-cell-sortable' ) ) ;
1067
- const headerTitle = sortableHeader . query ( By . css ( '.ui-grid-header-title' ) ) ;
1068
-
1069
- const [ column ] = grid . columns . toArray ( ) ;
1070
-
1071
- column . sort = '' ;
1072
- fixture . detectChanges ( ) ;
1073
-
1074
- grid . sortChange
1075
- . pipe (
1076
- take ( 1 ) ,
1077
- finalize ( done ) ,
1078
- ) . subscribe ( sort => {
1079
- expect ( sort . direction ) . toBe ( 'asc' ) ;
1080
- expect ( sort . direction ) . toBe ( column . sort ) ;
1081
- expect ( sort . field ) . toBe ( column . property ! ) ;
1082
- } ) ;
1083
-
1084
- headerTitle . nativeElement . dispatchEvent ( EventGenerator . click ) ;
1085
- fixture . detectChanges ( ) ;
1086
- } ) ;
1087
-
1088
- SORT_KEY_EVENTS . forEach ( ev => {
1089
- it ( `should emit sort event when key '${ ev . key } ' is pressed ('${
1090
- sortTransition . from } ' to '${ sortTransition . to } ')`, ( done ) => {
1091
1089
const sortableHeader = fixture . debugElement . query ( By . css ( '.ui-grid-header-cell-sortable' ) ) ;
1090
+ const headerTitle = sortableHeader . query ( By . css ( '.ui-grid-header-title' ) ) ;
1091
+
1092
1092
const [ column ] = grid . columns . toArray ( ) ;
1093
1093
1094
1094
column . sort = '' ;
@@ -1104,9 +1104,32 @@ describe('Component: UiGrid', () => {
1104
1104
expect ( sort . field ) . toBe ( column . property ! ) ;
1105
1105
} ) ;
1106
1106
1107
- sortableHeader . nativeElement . dispatchEvent ( ev ) ;
1107
+ headerTitle . nativeElement . dispatchEvent ( EventGenerator . click ) ;
1108
1108
fixture . detectChanges ( ) ;
1109
1109
} ) ;
1110
+
1111
+ SORT_KEY_EVENTS . forEach ( ev => {
1112
+ it ( `should emit sort event when key '${ ev . key } ' is pressed ('${
1113
+ sortTransition . from } ' to '${ sortTransition . to } ')`, ( done ) => {
1114
+ const sortableHeader = fixture . debugElement . query ( By . css ( '.ui-grid-header-cell-sortable' ) ) ;
1115
+ const [ column ] = grid . columns . toArray ( ) ;
1116
+
1117
+ column . sort = '' ;
1118
+ fixture . detectChanges ( ) ;
1119
+
1120
+ grid . sortChange
1121
+ . pipe (
1122
+ take ( 1 ) ,
1123
+ finalize ( done ) ,
1124
+ ) . subscribe ( sort => {
1125
+ expect ( sort . direction ) . toBe ( 'asc' ) ;
1126
+ expect ( sort . direction ) . toBe ( column . sort ) ;
1127
+ expect ( sort . field ) . toBe ( column . property ! ) ;
1128
+ } ) ;
1129
+
1130
+ sortableHeader . nativeElement . dispatchEvent ( ev ) ;
1131
+ fixture . detectChanges ( ) ;
1132
+ } ) ;
1110
1133
} ) ;
1111
1134
} ) ;
1112
1135
} ) ;
0 commit comments