Skip to content

Commit 58c6bbf

Browse files
committed
test(mdv): adding paging tests #5880
1 parent bbed683 commit 58c6bbf

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

Diff for: projects/igniteui-angular/src/lib/grids/grid/grid.master-detail.spec.ts

+52-1
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,59 @@ describe('IgxGrid Master Detail', () => {
129129
});
130130
});
131131
});
132+
133+
describe('Integration', () => {
134+
configureTestSuite();
135+
beforeEach(async(() => {
136+
TestBed.configureTestingModule({
137+
declarations: [
138+
DefaultGridMasterDetailComponent
139+
],
140+
imports: [IgxGridModule, NoopAnimationsModule]
141+
}).compileComponents();
142+
}));
143+
144+
describe('Paging', () => {
145+
it('Should not take into account expanded detail views as additional records.', () => {
146+
fix = TestBed.createComponent(DefaultGridMasterDetailComponent);
147+
fix.componentInstance.paging = true;
148+
grid = fix.componentInstance.grid;
149+
fix.detectChanges();
150+
const initialTotalRecords = grid.pagingState.metadata.countRecords;
151+
grid.expand(fix.componentInstance.data[0].ID);
152+
fix.detectChanges();
153+
expect(grid.pagingState.metadata.countRecords).toEqual(initialTotalRecords);
154+
});
155+
156+
it('Should persist template state after paging to a page with fewer records and paging back.', () => {
157+
fix = TestBed.createComponent(DefaultGridMasterDetailComponent);
158+
fix.componentInstance.paging = true;
159+
fix.componentInstance.perPage = 5;
160+
grid = fix.componentInstance.grid;
161+
fix.detectChanges();
162+
grid.expand(fix.componentInstance.data[4].ID);
163+
fix.detectChanges();
164+
// click the template checkbox
165+
let checkbox = fix.debugElement.query(By.css('.igx-checkbox__input'));
166+
checkbox.nativeElement.click();
167+
fix.detectChanges();
168+
// go to last page that doesn't contain this view
169+
grid.page = grid.pagingState.metadata.countPages - 1;
170+
fix.detectChanges();
171+
// go back to first page
172+
grid.page = 0;
173+
fix.detectChanges();
174+
// check checkbox state
175+
checkbox = fix.debugElement.query(By.css('.igx-checkbox__input'));
176+
expect(checkbox.nativeElement.attributes['aria-checked'].value).toEqual('true');
177+
});
178+
});
179+
});
132180
});
133181

134182
@Component({
135183
template: `
136-
<igx-grid [data]="data" [width]="width" [height]="height" [primaryKey]="'ID'" [paging]="paging" [rowSelectable]="rowSelectable">
184+
<igx-grid [data]="data" [width]="width" [height]="height" [primaryKey]="'ID'" [paging]="paging" [perPage]="perPage" [rowSelectable]="rowSelectable">
137185
<igx-column *ngFor="let c of columns" [field]="c.field" [header]="c.field" [width]="c.width" [dataType]='c.dataType'
138186
[hidden]='c.hidden' [sortable]="c.sortable" [movable]='c.movable' [groupable]='c.groupable' [editable]="c.editable"
139187
[hasSummary]="c.hasSummary" [pinned]='c.pinned'>
@@ -162,8 +210,11 @@ export class DefaultGridMasterDetailComponent {
162210
{ field: 'CompanyName', width: 400, dataType: 'string' }
163211
];
164212
public paging = false;
213+
public perPage = 15;
165214
public rowSelectable = false;
166215

216+
public onCheckboxClicked = () => {};
217+
167218
@ViewChild(IgxGridComponent, { read: IgxGridComponent, static: true })
168219
public grid: IgxGridComponent;
169220

0 commit comments

Comments
 (0)