Skip to content

Commit bc56486

Browse files
authored
Merge pull request #2431 from Licen-it/master
fix(ColumnDirective): fixed missing class if no inputs provided
2 parents a4b0b80 + bb5af3f commit bc56486

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/grid/grid.directive.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,28 @@ describe("GridDirective", () => {
8080
);
8181
});
8282
}));
83+
84+
it("should render a column without inputs", async(() => {
85+
TestBed.overrideComponent(TestGridComponent, {
86+
set: {
87+
template:
88+
`<div ibmCol></div>`
89+
}
90+
});
91+
92+
TestBed.compileComponents().then(() => {
93+
const fixture = TestBed.createComponent(TestGridComponent);
94+
const directiveEl = fixture.debugElement.query(
95+
By.directive(ColumnDirective)
96+
);
97+
fixture.detectChanges();
98+
99+
expect(directiveEl).not.toBeNull();
100+
101+
const directiveInstance = directiveEl.injector.get(ColumnDirective);
102+
expect(directiveInstance.columnClasses).toBe(
103+
"bx--col"
104+
);
105+
});
106+
}));
83107
});

src/grid/grid.directive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export class ColumnDirective implements OnChanges {
4949

5050
@Input() offsets = {};
5151

52-
protected _columnClasses: string[] = [];
52+
// initial value if no inputs are provided (if no inputs ngOnChanges won't be executed)
53+
protected _columnClasses: string[] = ["bx--col"];
5354

5455
@HostBinding("class")
5556
get columnClasses(): string {

0 commit comments

Comments
 (0)