Skip to content

Commit

Permalink
chore(Table): has test for warning
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #1392
  • Loading branch information
shani-terminus committed Mar 15, 2019
1 parent 7b09ec3 commit 41673d6
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions terminus-ui/table/src/table.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,40 @@ class TableColumnAlignmentTableApp {
}


@Component({
template: `
<ts-table [dataSource]="dataSource" tsSort>
<ng-container tsColumnDef="column_a" alignment="top">
<ts-header-cell *tsHeaderCellDef>Column A</ts-header-cell>
<ts-cell *tsCellDef="let row">{{ row.a }}</ts-cell>
</ng-container>
<ts-header-row *tsHeaderRowDef="columnsToRender"></ts-header-row>
<ts-row *tsRowDef="let row; columns: columnsToRender"></ts-row>
</ts-table>
`,
})
class TableColumnInvalidAlignmentTableApp {
underlyingDataSource = new FakeDataSource();
dataSource = new TsTableDataSource<TestData>();
columnsToRender = ['column_a'];

@ViewChild(TsTableComponent) table!: TsTableComponent<TestData>;

constructor() {
this.underlyingDataSource.data = [];

// Add a row of data
this.underlyingDataSource.addData();

this.underlyingDataSource.connect().subscribe((data) => {
this.dataSource.data = data;
});
}

}




// Utilities copied from CDKTable's spec
Expand Down Expand Up @@ -449,7 +483,18 @@ describe(`TsTableComponent`, function() {

expect(style).toBeUndefined();
});
});

describe(`invalid alignment argument`, () => {
test(`should throw warning`, () => {
window.console.warn = jest.fn();
let fixture: ComponentFixture<TableColumnInvalidAlignmentTableApp>;

fixture = createComponent(TableColumnInvalidAlignmentTableApp);
fixture.detectChanges();

expect(window.console.warn).toHaveBeenCalled();
});
});

});
Expand Down

0 comments on commit 41673d6

Please sign in to comment.