Comparto mi solución del reto
it('should show a selected person', () => {
// Arrange
const personList = [
new Person('Peter', 'Parker', 24, 70, 1.7),
new Person('Armando', 'Rivera', 24, 80, 1.8),
new Person('Bruce', 'Wayne', 24, 80, 1.8),
];
component.personList = personList;
// Act
fixture.detectChanges();
const debugButtonList = fixture.debugElement.queryAll(
By.css('app-person .btn-choose')
);
debugButtonList[0].triggerEventHandler('click', null);
fixture.detectChanges();
const debugPersonSelectedInfo = fixture.debugElement.queryAll(
By.css('.selectedPerson ul li')
);
// Assert
expect(debugPersonSelectedInfo[0].nativeElement.textContent).toContain(
personList[0].name
);
expect(debugPersonSelectedInfo[1].nativeElement.textContent).toContain(
personList[0].age
);
});
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?