📅  最后修改于: 2022-03-11 14:48:15.046000             🧑  作者: Mango
// Define component and fixture within describe()
it('should click button', fakeAsync(() => {
spyOn(component, 'methodName');
let btn = fixture.debugElement.query(By.css('.btn-class'));
btn.triggerEventHandler('click', null);
fixture.detectChanges();
expect(component.methodName).toHaveBeenCalled();
}))