Skip to content

Commit fd766ec

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Add detailsTemplate test.
1 parent 4fc261c commit fd766ec

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild, OnInit, DebugElement, QueryList } from '@angular/core';
1+
import { Component, ViewChild, OnInit, DebugElement, QueryList, TemplateRef } from '@angular/core';
22
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
33
import { configureTestSuite } from '../../test-utils/configure-suite';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
@@ -346,6 +346,17 @@ describe('IgxGrid Master Detail #grid', () => {
346346
expect(row.expanded).toBeFalsy();
347347
});
348348
});
349+
350+
it('should allow setting external details template via Input.', () => {
351+
grid = fix.componentInstance.grid;
352+
grid.detailTemplate = fix.componentInstance.detailTemplate;
353+
fix.detectChanges();
354+
grid.toggleRow(fix.componentInstance.data[0].ID);
355+
fix.detectChanges();
356+
const gridRows = grid.rowList.toArray();
357+
const firstDetail = GridFunctions.getMasterRowDetail(gridRows[0]);
358+
expect(firstDetail.textContent.trim()).toBe('NEW TEMPLATE');
359+
});
349360
});
350361

351362
describe('Keyboard Navigation ', () => {
@@ -1257,12 +1268,20 @@ describe('IgxGrid Master Detail #grid', () => {
12571268
</div>
12581269
</ng-template>
12591270
</igx-grid>
1271+
<ng-template igxGridDetail let-dataItem #detailTemplate>
1272+
<div>
1273+
NEW TEMPLATE
1274+
</div>
1275+
</ng-template>
12601276
`
12611277
})
12621278
export class DefaultGridMasterDetailComponent {
12631279
@ViewChild(IgxGridComponent, { read: IgxGridComponent, static: true })
12641280
public grid: IgxGridComponent;
12651281

1282+
@ViewChild('detailTemplate', { read: TemplateRef, static: true })
1283+
public detailTemplate: TemplateRef<any>;
1284+
12661285
public width = '800px';
12671286
public height = '500px';
12681287
public data = SampleTestData.contactInfoDataFull();

0 commit comments

Comments
 (0)