I am trying to unit test inner data in Angular 15 functional guard, see the last condition. Need to make sure the error message appears if user has no license.
How can that be done without public properties/functions?
Please help,
I am new to functional guards.
TIA, Oleg.
export const isAuthGuardFn: CanActivateFn = (route: ActivatedRouteSnapshot) => {
return checkUserLogin(route);
}
const checkUserLogin = async (route: ActivatedRouteSnapshot): Promise<boolean> => {
const msgService = inject(MessageService);
const _userLoginInfoService = inject(UserLoginInfoService);
let userLoginInfo = USERLOGININFOEMPTYDATA;
_userLoginInfoService.retrieveLoginInfo();
_userLoginInfoService.userLoginInfo$.subscribe(loginInfo => userLoginInfo = loginInfo);
if (!userLoginInfo.licensed) {
msgService.add({ severity: 'error', summary: 'Error', detail: 'You do not have a license. Please contact your system administrator.' });
}