Skip to content

Commit

Permalink
test(grid): add test for a column width in % #1245
Browse files Browse the repository at this point in the history
  • Loading branch information
DiyanDimitrov committed Nov 28, 2018
1 parent 69e8242 commit c024a88
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ describe('IgxGrid Component Tests', () => {
TestBed.configureTestingModule({
declarations: [
IgxGridDefaultRenderingComponent,
IgxGridColumnPercentageWidthComponent,
IgxGridWrappedInContComponent,
IgxGridFormattingComponent
],
Expand Down Expand Up @@ -751,6 +752,16 @@ describe('IgxGrid Component Tests', () => {
}
});
});

fit('Should calculate default column width when a column has width in %', () => {
const fix = TestBed.createComponent(IgxGridColumnPercentageWidthComponent);
fix.componentInstance.initColumnsRows(5, 3);
fix.detectChanges();

const grid = fix.componentInstance.grid;
expect(grid.columns[1].width).toEqual('150');
expect(grid.columns[1].width).toEqual('150');
});
});

describe('IgxGrid - keyboard navigation tests', () => {
Expand Down Expand Up @@ -3168,6 +3179,20 @@ export class IgxGridDefaultRenderingComponent {
}
}

@Component({
template: `<igx-grid #grid [data]="data" [width]="'500px'" (onColumnInit)="initColumns($event)">
<igx-column *ngFor="let col of columns" [field]="col.key" [header]="col.key" [dataType]="col.dataType">
</igx-column>
</igx-grid>`
})
export class IgxGridColumnPercentageWidthComponent extends IgxGridDefaultRenderingComponent {
public initColumns(column) {
if (column.index === 0) {
column.width = '40%';
}
}
}

@Component({
template:
`<div [style.width.px]="outerWidth" [style.height.px]="outerHeight">
Expand Down

0 comments on commit c024a88

Please sign in to comment.