Skip to content

Commit 8ebe5cf

Browse files
MKirovaMKirova
authored andcommitted
Add expand collapse test.
1 parent 403c045 commit 8ebe5cf

File tree

1 file changed

+107
-1
lines changed

1 file changed

+107
-1
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.pipes.spec.ts

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,120 @@ describe('Pivot pipes', () => {
106106
]);
107107
});
108108

109+
it('allows setting expand/collapse state.', () => {
110+
const expanded = new Map<any, boolean>();
111+
expanded.set('All', false);
112+
const rowPipeCollapseResult = rowPipe.transform(data, pivotConfigHierarchy.rows, expanded, pivotConfigHierarchy.values);
113+
expect(rowPipeCollapseResult).toEqual([
114+
{ field1:'All',records: [
115+
{
116+
field1:'Clothing',
117+
records:[
118+
{ProductCategory:'Clothing',UnitPrice:12.81,SellerName:'Stanley',Country:'Bulgaria',Date:'01/01/2021',UnitsSold:282},
119+
{ProductCategory:'Clothing',UnitPrice:49.57,SellerName:'Elisa',Country:'USA',Date:'01/05/2019',UnitsSold:296},
120+
{ProductCategory:'Clothing',UnitPrice:68.33,SellerName:'Larry',Country:'Uruguay',Date:'05/12/2020',UnitsSold:456},
121+
{ProductCategory:'Clothing',UnitPrice:16.05,SellerName:'Walter',Country:'Bulgaria',Date:'02/19/2020',UnitsSold:492}
122+
]
123+
,level:1
124+
},
125+
{
126+
field1:'Bikes',
127+
records:[
128+
{ProductCategory:'Bikes',UnitPrice:3.56,SellerName:'Lydia',Country:'Uruguay',Date:'01/06/2020',UnitsSold:68}
129+
]
130+
,level:1
131+
},
132+
{
133+
field1:'Accessories',
134+
records:[
135+
{ProductCategory:'Accessories',UnitPrice:85.58,SellerName:'David',Country:'USA',Date:'04/07/2021',UnitsSold:293}
136+
]
137+
,level:1},
138+
{
139+
field1:'Components',
140+
records:[
141+
{ProductCategory:'Components',UnitPrice:18.13,SellerName:'John',Country:'USA',Date:'12/08/2021',UnitsSold:240}
142+
]
143+
,level:1}
144+
]
145+
,level:0}
146+
]);
147+
148+
expanded.set('All', true);
149+
const rowPipeExpandResult = rowPipe.transform(data, pivotConfigHierarchy.rows, expanded, pivotConfigHierarchy.values);
150+
expect(rowPipeExpandResult).toEqual([
151+
{ field1:'All',records: [
152+
{
153+
field1:'Clothing',
154+
records:[
155+
{ProductCategory:'Clothing',UnitPrice:12.81,SellerName:'Stanley',Country:'Bulgaria',Date:'01/01/2021',UnitsSold:282},
156+
{ProductCategory:'Clothing',UnitPrice:49.57,SellerName:'Elisa',Country:'USA',Date:'01/05/2019',UnitsSold:296},
157+
{ProductCategory:'Clothing',UnitPrice:68.33,SellerName:'Larry',Country:'Uruguay',Date:'05/12/2020',UnitsSold:456},
158+
{ProductCategory:'Clothing',UnitPrice:16.05,SellerName:'Walter',Country:'Bulgaria',Date:'02/19/2020',UnitsSold:492}
159+
]
160+
,level:1
161+
},
162+
{
163+
field1:'Bikes',
164+
records:[
165+
{ProductCategory:'Bikes',UnitPrice:3.56,SellerName:'Lydia',Country:'Uruguay',Date:'01/06/2020',UnitsSold:68}
166+
]
167+
,level:1
168+
},
169+
{
170+
field1:'Accessories',
171+
records:[
172+
{ProductCategory:'Accessories',UnitPrice:85.58,SellerName:'David',Country:'USA',Date:'04/07/2021',UnitsSold:293}
173+
]
174+
,level:1},
175+
{
176+
field1:'Components',
177+
records:[
178+
{ProductCategory:'Components',UnitPrice:18.13,SellerName:'John',Country:'USA',Date:'12/08/2021',UnitsSold:240}
179+
]
180+
,level:1}
181+
]
182+
,level:0},
183+
{
184+
field1:'Clothing',
185+
records:[
186+
{ProductCategory:'Clothing',UnitPrice:12.81,SellerName:'Stanley',Country:'Bulgaria',Date:'01/01/2021',UnitsSold:282},
187+
{ProductCategory:'Clothing',UnitPrice:49.57,SellerName:'Elisa',Country:'USA',Date:'01/05/2019',UnitsSold:296},
188+
{ProductCategory:'Clothing',UnitPrice:68.33,SellerName:'Larry',Country:'Uruguay',Date:'05/12/2020',UnitsSold:456},
189+
{ProductCategory:'Clothing',UnitPrice:16.05,SellerName:'Walter',Country:'Bulgaria',Date:'02/19/2020',UnitsSold:492}
190+
]
191+
,level:1
192+
},
193+
{
194+
field1:'Bikes',
195+
records:[
196+
{ProductCategory:'Bikes',UnitPrice:3.56,SellerName:'Lydia',Country:'Uruguay',Date:'01/06/2020',UnitsSold:68}
197+
]
198+
,level:1
199+
},
200+
{
201+
field1:'Accessories',
202+
records:[
203+
{ProductCategory:'Accessories',UnitPrice:85.58,SellerName:'David',Country:'USA',Date:'04/07/2021',UnitsSold:293}
204+
]
205+
,level:1},
206+
{
207+
field1:'Components',
208+
records:[
209+
{ProductCategory:'Components',UnitPrice:18.13,SellerName:'John',Country:'USA',Date:'12/08/2021',UnitsSold:240}
210+
]
211+
,level:1}
212+
]);
213+
});
214+
109215
it('transforms flat data to pivot data multiple row dimensions', () => {
110216
const rowPipeResult = rowPipe.transform(data, [{
111217
member: 'ProductCategory',
112218
enabled: true,
113219
childLevels: []
114220
},
115221
{
116-
member: 'Date',
222+
member: Date,
117223
enabled: true,
118224
childLevels: []
119225
}], expansionStates, pivotConfigHierarchy.values);

0 commit comments

Comments
 (0)