mercredi 30 janvier 2019

Angular testing observable in service

I would like to test function in service. But i can't test subscribe. How can i do this?

Function to test:

  getInvestigates(page, lim): any {
    return this.http.get(`${this.bcUrl}/api/investigates?page=${page}&size=${lim}`, this.httpOptions)
      .subscribe(
        (data: DataInterface) => {
          this.investigates = data.content;
          this.st.totalPages = data.totalPages;
          this.st.totalElements = data.totalElements;
        },
        error => {
          if (error.status === 404) {
            alert('Not found');
          }
        });
  }

Aucun commentaire:

Enregistrer un commentaire