I'm having trouble with the following.
This is a unit test for a directive, the directive itself should simply change the height
style property for the element it's on. I am using a test component as a context for this test. The trouble is the styles seem to always be empty no matter what I do.
I am setting background-color
explicitly in the component just to see if it comes though at the other end in the fixture.debugElement
@Component({
template: `
<style>
.test {
background-color: white;
}
</style>
<div class="test" appExpandSidebarToBottom></div>`
})
class TestComponent {
constructor(){}
}
fdescribe('Directive: ExpandSidebarToBottom', () => {
let fixture;
let divWithDirective;
beforeEach(() => {
fixture = TestBed.configureTestingModule({
declarations: [ ExpandSidebarToBottomDirective, TestComponent ]
})
.createComponent(TestComponent);
fixture.detectChanges(); // initial binding
divWithDirective = fixture.debugElement.query(By.css('.test'));
});
it('should...', () => {
console.log(divWithDirective.nativeElement.backgroundColor)
console.log(divWithDirective.styles)
});
});
The output is
LOG: undefined
LOG: Object{}
Where are the styles defined in the component?