import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HexToRgbPipe } from '@pipes'; import { SwatchComponent } from './swatch.component'; describe('SwatchComponent', () => { let component: SwatchComponent; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ SwatchComponent, HexToRgbPipe, ], }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(SwatchComponent); component = fixture.componentInstance; component.hex = '#ee0000'; fixture.detectChanges(); }); it('creates the component', () => { expect(component).toBeTruthy(); }); describe('setSwatchStyles()', () => { it('sets the appropriate background color on the color swatch element', () => { component.setSwatchStyles(); fixture.detectChanges(); expect(fixture.nativeElement.querySelector('.ta-swatch__block').style.backgroundColor).toBe('rgb(238, 0, 0)'); }) }); });