import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; import { FeedbackButtonComponent } from './feedback-button.component'; import {FormsModule} from '@angular/forms'; import {MatIconModule} from '@angular/material/icon'; describe('FeedbackButtonComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [FormsModule, MatIconModule], declarations: [FeedbackButtonComponent] }) .compileComponents(); })); it('errors when no title is given', () => { const component = new FeedbackButtonComponent(); expect(() => component.ngOnInit()).toThrowError('Please provide a title for the feedback button!'); }); it('renders when given a title', () => { const fixture = TestBed.createComponent(FeedbackButtonComponent); const component = fixture.componentInstance; component.title = 'someTitle'; fixture.detectChanges(); expect(fixture.nativeElement.innerHTML).toContain('someTitle'); }); });