lundi 4 juin 2018

Testing function submit() in Component + Service, using Angular 5

I need to test function submit. I have this code:

onAddProd() {
    this.areWeWaiting = true;
    let newProd= new Product(
      this.addProdForm.value
    );
    this.ws.createProduct(newProd).subscribe( //createProduct is function service
      result => {
        if (result === true) {
          this.router.navigate(['/home']);
        } else {
          this.areWeWaiting = false;
        }
      },
      error => {
        this.areWeWaiting = false;
      }
    );
  }

I need basically testing. - If result is true should be navigate ti /home

Can you suggest me any idea please?

Aucun commentaire:

Enregistrer un commentaire