I want to create a test that checks that there is binding between background color and component property.
Component template snippet
<div
class="colored-div"
[style.background-color]="color"
</div>
Test
it('background should have correct color', () => {
component.color = '#000000';
fixture.detectChanges();
const colorEl: HTMLElement = fixture.debugElement.query(By.css('.colored-div')).nativeElement;
expect(colorEl.style.backgroundColor).toBe('#000000');
});
I expect to pass this test, but angular converts background color to rgb and test fails with error: "Expected 'rgb(0, 0, 0)' to be '#000000'". So the question is: is there a way to stop angular from converting value to rgb or should I change my test assertion to
expect(colorEl.style.backgroundColor).toBe('rgb(0, 0, 0)');