Ajax S
Ajax S

Reputation: 1

Test cases for Angular Components with Ngrx Store

I want to write test case for the following .I have tried with the following code but didnt work at all.

Been Searching for this since few hours but no solution.

  ngOnInit(): void {
        this.isDarkTheme$ = this.themeService.getDarkTheme();
        this.store.select(selectUser).subscribe((data) => {
          this.role = data.role.name;
          this.firstName = data.firstName;
          this.lastName = data.lastName;
          this.menuItems = menuItems(this.role);
        });
      }

describe('test', () => {
    it('should get userData from the store', () => {
      const role:string = "admin";
      const firstName:string = "Jim";
      const lastName:string = "Becker";
      const menuItems:MenuItems[] = [
        {
          key: 'dashboard',
          label: 'DASHBOARD',
          url: '/tiles/dashboard',
          icon: 'pi pi-fw pi-sign-out',
        },
        {
          key: 'teams',
          label: 'TEAMS',
          url: '/tiles/teams',
          icon: 'pi pi-fw pi-users',
        },
      ];
      const mockHomeState = store.overrideSelector(
        selectUser,
      menuItems
      );

      component.ngOnInit();
    });
  });

Upvotes: 0

Views: 59

Answers (0)

Related Questions