1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How do you unit test if statements in angular

Discussão em 'Angular' iniciado por Pam Halligan-Sims, Outubro 16, 2024.

  1. 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');
    }
    }

    getPreferences() { return this.store.select('user').map((state: User) => state); }

    Continue reading...

Compartilhe esta Página