|
1 | 1 | import { Component, ViewChild, OnInit } from '@angular/core'; |
2 | | -import { async, TestBed, ComponentFixture } from '@angular/core/testing'; |
| 2 | +import { async, TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; |
3 | 3 | import { configureTestSuite } from '../../test-utils/configure-suite'; |
4 | 4 | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; |
5 | 5 | import { By } from '@angular/platform-browser'; |
@@ -799,10 +799,13 @@ describe('IgxGrid Master Detail #grid', () => { |
799 | 799 | }); |
800 | 800 |
|
801 | 801 | describe('Cell Selection', () => { |
802 | | - it('Should exclude expanded detail views when doing range cell selection', () => { |
| 802 | + beforeEach(fakeAsync(() => { |
803 | 803 | fix = TestBed.createComponent(DefaultGridMasterDetailComponent); |
804 | 804 | grid = fix.componentInstance.grid; |
805 | 805 | fix.detectChanges(); |
| 806 | + })); |
| 807 | + |
| 808 | + it('Should exclude expanded detail views when doing range cell selection', fakeAsync(() => { |
806 | 809 | grid.expandRow(fix.componentInstance.data[2].ID); |
807 | 810 | const selectionChangeSpy = spyOn<any>(grid.onRangeSelection, 'emit').and.callThrough(); |
808 | 811 | const startCell = grid.getCellByColumn(1, 'ContactName'); |
@@ -837,7 +840,23 @@ describe('IgxGrid Master Detail #grid', () => { |
837 | 840 | expect(selectionChangeSpy).toHaveBeenCalledTimes(1); |
838 | 841 | expect(selectionChangeSpy).toHaveBeenCalledWith(range); |
839 | 842 | expect(rowDetail.querySelector('[class*="selected"]')).toBeNull(); |
840 | | - }); |
| 843 | + })); |
| 844 | + |
| 845 | + it('getSelectedData should return correct values when there are master details', fakeAsync(() => { |
| 846 | + const range = { rowStart: 0, rowEnd: 5, columnStart: 'ContactName', columnEnd: 'ContactName' }; |
| 847 | + const expectedData = [ |
| 848 | + { ContactName: 'Maria Anders' }, |
| 849 | + { ContactName: 'Ana Trujillo' }, |
| 850 | + { ContactName: 'Antonio Moreno' } |
| 851 | + ]; |
| 852 | + grid.expandAll(); |
| 853 | + tick(100); |
| 854 | + fix.detectChanges(); |
| 855 | + |
| 856 | + grid.selectRange(range); |
| 857 | + fix.detectChanges(); |
| 858 | + expect(grid.getSelectedData()).toEqual(expectedData); |
| 859 | + })); |
841 | 860 | }); |
842 | 861 |
|
843 | 862 | describe('Row Selection', () => { |
@@ -1070,10 +1089,12 @@ describe('IgxGrid Master Detail #grid', () => { |
1070 | 1089 | describe('GroupBy', () => { |
1071 | 1090 | beforeEach(async() => { |
1072 | 1091 | fix = TestBed.createComponent(DefaultGridMasterDetailComponent); |
1073 | | - fix.componentInstance.columns[0].hasSummary = true; |
1074 | 1092 | fix.detectChanges(); |
1075 | 1093 |
|
1076 | 1094 | grid = fix.componentInstance.grid; |
| 1095 | + grid.getColumnByName('ContactName').hasSummary = true; |
| 1096 | + fix.detectChanges(); |
| 1097 | + |
1077 | 1098 | grid.summaryCalculationMode = GridSummaryCalculationMode.childLevelsOnly; |
1078 | 1099 | grid.groupingExpressions = |
1079 | 1100 | [{ fieldName: 'CompanyName', dir: SortingDirection.Asc, ignoreCase: false }]; |
@@ -1162,9 +1183,7 @@ describe('IgxGrid Master Detail #grid', () => { |
1162 | 1183 | template: ` |
1163 | 1184 | <igx-grid [data]="data" [width]="width" [height]="height" [primaryKey]="'ID'" [allowFiltering]='true' |
1164 | 1185 | [paging]="paging" [perPage]="perPage" [rowSelectable]="rowSelectable"> |
1165 | | - <igx-column *ngFor="let c of columns" [field]="c.field" [header]="c.field" [width]="c.width" [dataType]='c.dataType' |
1166 | | - [hidden]='c.hidden' [sortable]="c.sortable" [movable]='c.movable' [groupable]='c.groupable' [editable]="c.editable" |
1167 | | - [hasSummary]="c.hasSummary" [pinned]='c.pinned'> |
| 1186 | + <igx-column *ngFor="let c of columns" [field]="c.field" [width]="c.width" [dataType]='c.dataType'> |
1168 | 1187 | </igx-column> |
1169 | 1188 |
|
1170 | 1189 | <ng-template igxGridDetail let-dataItem> |
@@ -1203,9 +1222,7 @@ export class DefaultGridMasterDetailComponent { |
1203 | 1222 | template: ` |
1204 | 1223 | <igx-grid [data]="data" [expansionStates]='expStates' |
1205 | 1224 | [width]="width" [height]="height" [primaryKey]="'ID'" [paging]="paging" [rowSelectable]="rowSelectable"> |
1206 | | - <igx-column *ngFor="let c of columns" [field]="c.field" [header]="c.field" [width]="c.width" [dataType]='c.dataType' |
1207 | | - [hidden]='c.hidden' [sortable]="c.sortable" [movable]='c.movable' [groupable]='c.groupable' [editable]="c.editable" |
1208 | | - [hasSummary]="c.hasSummary" [pinned]='c.pinned'> |
| 1225 | + <igx-column *ngFor="let c of columns" [field]="c.field" [header]="c.field" [width]="c.width" [dataType]='c.dataType'> |
1209 | 1226 | </igx-column> |
1210 | 1227 |
|
1211 | 1228 | <ng-template igxGridDetail let-dataItem> |
|
0 commit comments