mercredi 30 août 2017

How do I test onSelect function in a table (Angular 2)?

Right now I am trying to test some components in my Angular 2 project. I've got a table, which is getting the whole content from a database. You can select one of these rows get to the onSelect() function.

<tbody>
  <tr *ngFor="let c of Contents" [class.selected]="c.content === selectedContent" (click)="onSelect(c.content)" >
     <td>  </td>
     <td> </td>
     <td> </td>
  </tr>
</tbody>

And the function onSelect():

onSelect(contents: Content): void {
    this.selectedContent = contents;
    var url =  configuration.baseURL + contents.content;
    this.detailsContent.update(url);
}

So, how do I test that onSelect is called, when I click on the first Content?

Aucun commentaire:

Enregistrer un commentaire