/** * Button input Component Tests */ import { DebugElement } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { ButtonComponent } from './button.component'; describe('Button Element Component', () => { let comp: ButtonComponent; let fixture: ComponentFixture; let de: DebugElement; let el: HTMLElement; beforeEach(() => { TestBed.configureTestingModule({ declarations: [ ButtonComponent ], }); fixture = TestBed.createComponent(ButtonComponent); comp = fixture.componentInstance; de = fixture.debugElement.query(By.css('button')); el = de.nativeElement; }); it('button should exist', () => { fixture.detectChanges(); expect(el).toBeTruthy(); }); it('default button text should be button', () => { fixture.detectChanges(); expect(el.textContent).toEqual('button'); }); it('button text should be updated on attribute change', () => { comp.buttonText = 'submit'; fixture.detectChanges(); expect(el.textContent).toEqual('submit'); }); });