mardi 28 novembre 2017

How do you unit test if statements in angular

I have a function that subscribes a response from the NGRX store then uses the variable provided to change a message.

How do I test that the message changes when the variable updates?

  getData() {
    this.service.getPreferences().subscribe(res => {
      this.mypreference$ = res.mypreference;
    });
    if (this.mypreference$ == false) {
      (this.mypreferenceType = 'noPreference');
    } else {
      (this.mypreferenceType = 'Preference');
    }
  }

Aucun commentaire:

Enregistrer un commentaire