我想为以下编写测试用例。我尝试过使用以下代码,但根本没有用。
几个小时以来一直在寻找这个,但没有解决方案。
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();
});
});