[ADF-966] added the ability to reflect data change on datatable (#2042)

* [ADF - 966] added a setTimeout to test the async loading of datatable

* [ADF-966] added the ability to reflect changes on data change

* [ADF-917] changed due PR
This commit is contained in:
Vito
2017-07-05 04:39:50 -07:00
committed by Eugenio Romano
parent 44446b73c4
commit 866cb121fb
4 changed files with 65 additions and 6 deletions

View File

@@ -66,6 +66,31 @@ describe('DataTable', () => {
};
});
it('should change the rows on changing of the data', () => {
let newData = new ObjectDataTableAdapter(
[
{ name: 'TEST' },
{ name: 'FAKE' }
],
[new ObjectDataColumn({ key: 'name' })]
);
dataTable.data = new ObjectDataTableAdapter(
[
{ name: '1' },
{ name: '2' }
],
[new ObjectDataColumn({ key: 'name' })]
);
dataTable.ngOnChanges({
data: new SimpleChange(null, newData, false)
});
fixture.detectChanges();
expect(element.querySelector('[data-automation-id="text_TEST"]')).not.toBeNull();
expect(element.querySelector('[data-automation-id="text_FAKE"]')).not.toBeNull();
});
it('should reset selection on mode change', () => {
spyOn(dataTable, 'resetSelection').and.callThrough();

View File

@@ -133,6 +133,8 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
if (this.isPropertyChanged(changes['data'])) {
if (this.isTableEmpty()) {
this.initTable();
}else {
this.data = changes['data'].currentValue;
}
return;
}