Skip to content

Commit 0c7a0b8

Browse files
committed
test(filtering): add filtering event tests for more column types
1 parent 854ba65 commit 0c7a0b8

File tree

3 files changed

+140
-15
lines changed

3 files changed

+140
-15
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 118 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,7 +2746,37 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
27462746
grid,
27472747
100,
27482748
'Downloads',
2749-
IgxStringFilteringOperand.instance().condition('equals')
2749+
IgxNumberFilteringOperand.instance().condition('equals')
2750+
);
2751+
}));
2752+
2753+
it('Should emit filteringDone when we clicked reset - Currency column type', fakeAsync(() => {
2754+
emitFilteringDoneOnResetClick(
2755+
fix,
2756+
grid,
2757+
100000,
2758+
'Revenue',
2759+
IgxNumberFilteringOperand.instance().condition('equals')
2760+
);
2761+
}));
2762+
2763+
it('Should emit filteringDone when we clicked reset - Boolean column type', fakeAsync(() => {
2764+
emitFilteringDoneOnResetClick(
2765+
fix,
2766+
grid,
2767+
true,
2768+
'Released',
2769+
IgxBooleanFilteringOperand.instance().condition('true')
2770+
);
2771+
}));
2772+
2773+
it('Should emit filteringDone when we clicked reset - DateTime column type', fakeAsync(() => {
2774+
emitFilteringDoneOnResetClick(
2775+
fix,
2776+
grid,
2777+
cal.timedelta(today, 'hour', 1),
2778+
'ReleaseTime',
2779+
IgxDateTimeFilteringOperand.instance().condition('equals')
27502780
);
27512781
}));
27522782

@@ -2776,7 +2806,37 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
27762806
grid,
27772807
3,
27782808
'Downloads',
2779-
IgxStringFilteringOperand.instance().condition('equals')
2809+
IgxNumberFilteringOperand.instance().condition('equals')
2810+
);
2811+
}));
2812+
2813+
it('Should emit filteringDone when clear the input of filteringUI - Currency column type', fakeAsync(() => {
2814+
emitFilteringDoneOnInputClear(
2815+
fix,
2816+
grid,
2817+
100000,
2818+
'Revenue',
2819+
IgxNumberFilteringOperand.instance().condition('equals')
2820+
);
2821+
}));
2822+
2823+
it('Should emit filteringDone when clear the input of filteringUI - Boolean column type', fakeAsync(() => {
2824+
emitFilteringDoneOnInputClear(
2825+
fix,
2826+
grid,
2827+
true,
2828+
'Released',
2829+
IgxBooleanFilteringOperand.instance().condition('true')
2830+
);
2831+
}));
2832+
2833+
it('Should emit filteringDone when clear the input of filteringUI - DateTime column type', fakeAsync(() => {
2834+
emitFilteringDoneOnInputClear(
2835+
fix,
2836+
grid,
2837+
cal.timedelta(today, 'hour', 1),
2838+
'ReleaseTime',
2839+
IgxDateTimeFilteringOperand.instance().condition('equals')
27802840
);
27812841
}));
27822842

@@ -2810,12 +2870,48 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
28102870
grid,
28112871
100,
28122872
'Downloads',
2813-
IgxStringFilteringOperand.instance().condition('equals'),
2873+
IgxNumberFilteringOperand.instance().condition('equals'),
28142874
1,
28152875
2
28162876
);
28172877
}));
28182878

2879+
it('should update UI when chip is removed from header cell - Currency column type.', fakeAsync(() => {
2880+
verifyRemoveChipFromHeader(
2881+
fix,
2882+
grid,
2883+
100000,
2884+
'Revenue',
2885+
IgxNumberFilteringOperand.instance().condition('equals'),
2886+
1,
2887+
7
2888+
);
2889+
}));
2890+
2891+
it('should update UI when chip is removed from header cell - Boolean column type.', fakeAsync(() => {
2892+
verifyRemoveChipFromHeader(
2893+
fix,
2894+
grid,
2895+
true,
2896+
'Released',
2897+
IgxBooleanFilteringOperand.instance().condition('true'),
2898+
3,
2899+
3
2900+
);
2901+
}));
2902+
2903+
it('should update UI when chip is removed from header cell - DateTime column type.', fakeAsync(() => {
2904+
verifyRemoveChipFromHeader(
2905+
fix,
2906+
grid,
2907+
cal.timedelta(today, 'hour', 1),
2908+
'ReleaseTime',
2909+
IgxDateTimeFilteringOperand.instance().condition('equals'),
2910+
3,
2911+
6
2912+
);
2913+
}));
2914+
28192915
it('should emit filteringDone after chip is close from filtering row - Date column type', fakeAsync(() => {
28202916
closeChipFromFiteringUIRow(fix, grid, 'ReleaseDate', 4);
28212917
}));
@@ -2827,6 +2923,18 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
28272923
it('should emit filteringDone after chip is close from filtering row - Number column type', fakeAsync(() => {
28282924
closeChipFromFiteringUIRow(fix, grid, 'Downloads', 7);
28292925
}));
2926+
2927+
it('should emit filteringDone after chip is close from filtering row - Currency column type', fakeAsync(() => {
2928+
closeChipFromFiteringUIRow(fix, grid, 'Revenue', 7);
2929+
}));
2930+
2931+
it('should emit filteringDone after chip is close from filtering row - Boolean column type', fakeAsync(() => {
2932+
closeChipFromFiteringUIRow(fix, grid, 'Released', 1);
2933+
}));
2934+
2935+
it('should emit filteringDone after chip is close from filtering row - DateTime column type', fakeAsync(() => {
2936+
closeChipFromFiteringUIRow(fix, grid, 'ReleaseTime', 4);
2937+
}));
28302938
});
28312939
});
28322940

@@ -5340,7 +5448,8 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
53405448
ReleaseDateTime: null,
53415449
ReleaseTime: new Date(2010, 4, 27, 23, 0, 0),
53425450
Released: false,
5343-
AnotherField: 'BWord'
5451+
AnotherField: 'BWord',
5452+
Revenue: 60000
53445453
},
53455454
{
53465455
Downloads: 127,
@@ -5350,7 +5459,8 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
53505459
ReleaseDateTime: null,
53515460
ReleaseTime: new Date(2021, 4, 27, 1, 0, 0),
53525461
Released: true,
5353-
AnotherField: 'bWord'
5462+
AnotherField: 'bWord',
5463+
Revenue: 50000
53545464
},
53555465
{
53565466
Downloads: 20,
@@ -5360,7 +5470,8 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
53605470
ReleaseDateTime: null,
53615471
ReleaseTime: new Date(2015, 4, 27, 12, 0, 0),
53625472
Released: null,
5363-
AnotherField: 'aWord'
5473+
AnotherField: 'aWord',
5474+
Revenue: 100000
53645475
}
53655476
];
53665477
fix.componentInstance.data = data;
@@ -6517,7 +6628,7 @@ const emitFilteringDoneOnInputClear = (fix, grid, filterVal, columnName, conditi
65176628

65186629
GridFunctions.clickFilterCellChip(fix, columnName);
65196630

6520-
spyOn(grid.filteringDone, 'emit');
6631+
// spyOn(grid.filteringDone, 'emit');
65216632

65226633
grid.filteringRow.onClearClick();
65236634
tick(100);

projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,12 @@ export class IgxGridFilteringComponent extends BasicGridComponent {
10911091
<igx-column width="100px" [field]="'AnotherField'" [header]="'Another Field'" [filterable]="filterable"
10921092
dataType="string" [filters]="customFilter">
10931093
</igx-column>
1094+
<igx-column width="100px" [field]="'ReleaseTime'" [header]="'Release Time'" [filterable]="filterable"
1095+
dataType="dateTime">
1096+
</igx-column>
1097+
<igx-column width="100px" [field]="'Revenue'" [header]="'Revenue'" [filterable]="filterable"
1098+
dataType="currency">
1099+
</igx-column>
10941100
</igx-grid>`
10951101
})
10961102
export class IgxGridDatesFilteringComponent extends BasicGridComponent {

projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,8 @@ export class SampleTestData {
17261726
ReleaseDateTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'hour', 1),
17271727
ReleaseTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'hour', 1),
17281728
Released: false,
1729-
AnotherField: 'a'
1729+
AnotherField: 'a',
1730+
Revenue: 100000
17301731
},
17311732
{
17321733
Downloads: 127,
@@ -1736,7 +1737,8 @@ export class SampleTestData {
17361737
ReleaseDateTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'hour', -1),
17371738
ReleaseTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'hour', -1),
17381739
Released: true,
1739-
AnotherField: 'a'
1740+
AnotherField: 'a',
1741+
Revenue: 40000
17401742
},
17411743
{
17421744
Downloads: 20,
@@ -1746,7 +1748,8 @@ export class SampleTestData {
17461748
ReleaseDateTime: null,
17471749
ReleaseTime: null,
17481750
Released: null,
1749-
AnotherField: 'a'
1751+
AnotherField: 'a',
1752+
Revenue: 9000
17501753
},
17511754
{
17521755
Downloads: null,
@@ -1756,7 +1759,8 @@ export class SampleTestData {
17561759
ReleaseDateTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'minute', -10),
17571760
ReleaseTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'minute', -10),
17581761
Released: true,
1759-
AnotherField: 'a'
1762+
AnotherField: 'a',
1763+
Revenue: 10000
17601764
},
17611765
{
17621766
Downloads: 100,
@@ -1766,7 +1770,8 @@ export class SampleTestData {
17661770
ReleaseDateTime: undefined,
17671771
ReleaseTime: undefined,
17681772
Released: false,
1769-
AnotherField: 'a'
1773+
AnotherField: 'a',
1774+
Revenue: 30000
17701775
},
17711776
{
17721777
Downloads: 702,
@@ -1776,7 +1781,8 @@ export class SampleTestData {
17761781
ReleaseDateTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'second', 20),
17771782
ReleaseTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'second', 20),
17781783
Released: null,
1779-
AnotherField: 'Custom'
1784+
AnotherField: 'Custom',
1785+
Revenue: 60000
17801786
},
17811787
{
17821788
Downloads: 0,
@@ -1786,7 +1792,8 @@ export class SampleTestData {
17861792
ReleaseDateTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'minute', +10),
17871793
ReleaseTime: SampleTestData.timeGenerator.timedelta(SampleTestData.todayFullDate, 'minute', +10),
17881794
Released: true,
1789-
AnotherField: 'custoM'
1795+
AnotherField: 'custoM',
1796+
Revenue: 10000
17901797
},
17911798
{
17921799
Downloads: 1000,
@@ -1796,7 +1803,8 @@ export class SampleTestData {
17961803
ReleaseDateTime: SampleTestData.todayFullDate,
17971804
ReleaseTime: SampleTestData.todayFullDate,
17981805
Released: undefined,
1799-
AnotherField: 'custom'
1806+
AnotherField: 'custom',
1807+
Revenue: 50000
18001808
}
18011809
]);
18021810

0 commit comments

Comments
 (0)