Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/cdk/table/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ describe('CdkTable', () => {
expect(tableElement.textContent!.trim()).not.toContain('No data');
});

it('should show the no data row if there is no data on init', () => {
fixture.destroy();
fixture = TestBed.createComponent(SimpleCdkTableApp);
fixture.componentInstance.dataSource.data = [];
fixture.detectChanges();
tableElement = fixture.nativeElement.querySelector('.cdk-table');
expect(tableElement.textContent!.trim()).toContain('No data');
});
});

it('should render no rows when the data is null', fakeAsync(() => {
Expand Down
1 change: 1 addition & 0 deletions src/cdk/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
this._renderRows = this._getAllRenderRows();
const changes = this._dataDiffer.diff(this._renderRows);
if (!changes) {
this._updateNoDataRow();
return;
}

Expand Down
9 changes: 9 additions & 0 deletions src/material-experimental/mdc-table/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ describe('MDC-based MatTable', () => {
expect(tbody.textContent.trim()).not.toContain('No data');
});

it('should show the no data row if there is no data on init', () => {
const fixture = TestBed.createComponent(MatTableApp);
fixture.componentInstance.dataSource!.data = [];
fixture.detectChanges();

const tbody = fixture.nativeElement.querySelector('tbody')!;
expect(tbody.textContent.trim()).toContain('No data');
});

});

it('should render with MatTableDataSource and sort', () => {
Expand Down
9 changes: 9 additions & 0 deletions src/material/table/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ describe('MatTable', () => {
expect(table.textContent.trim()).not.toContain('No data');
});

it('should show the no data row if there is no data on init', () => {
const fixture = TestBed.createComponent(MatTableApp);
fixture.componentInstance.dataSource!.data = [];
fixture.detectChanges();

const table = fixture.nativeElement.querySelector('.mat-table')!;
expect(table.textContent.trim()).toContain('No data');
});

});

it('should be able to render a table correctly with native elements', () => {
Expand Down