Skip to content

Instantly share code, notes, and snippets.

@marcel-ploch
Created March 22, 2019 15:26
Show Gist options
  • Save marcel-ploch/72e9b3f388e284e51a2858b85bf77256 to your computer and use it in GitHub Desktop.
Save marcel-ploch/72e9b3f388e284e51a2858b85bf77256 to your computer and use it in GitHub Desktop.
Test mit Selektoren und Spy's
it('should edit an element via button click', async(() => {
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
let matCards = compiled.querySelectorAll('mat-card');
expect(app.toDoList.length).toBe(matCards.length);
spyOn(app, 'openDialogEdit').and.callFake(() => {
app.editItem(1, {name: 'Edit'});
});
const deleteElement = compiled.querySelectorAll('button.edit');
deleteElement[0].click();
fixture.detectChanges();
fixture.whenStable().then(() => {
matCards = compiled.querySelectorAll('mat-card');
expect(4).toBe(matCards.length);
});
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment