Skip to content
Snippets Groups Projects
Commit 58cd8440 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-2500 show "Unbekannter Benutzer" if loading user profile has any error

parent 6fbfa4ed
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@
[userProfileStateResource]="userProfileStateResource">
</goofy-client-user-icon>
<div *ngIf="userProfileStateResource.resource">
<div *ngIf="userProfileStateResource.resource; else unknownUser">
<span data-test-class="user-profile-name">{{userProfileStateResource.resource.firstName}} {{userProfileStateResource.resource.lastName}}</span>
</div>
<ng-template #unknownUser>
<span data-test-class="user-profile-name-unknown">Unbekannter Benutzer</span>
</ng-template>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createEmptyStateResource, createStateResource } from '@goofy-client/tech-shared';
import { createEmptyStateResource, createErrorStateResource, createStateResource } from '@goofy-client/tech-shared';
import { UserProfileResource } from '@goofy-client/user-profile-shared';
import { getDataTestClassOf } from 'libs/tech-shared/test/data-test';
import { createApiError } from 'libs/tech-shared/test/error';
import { createUserProfileResource } from 'libs/user-profile-shared/test/user-profile';
import { MockComponent } from 'ng-mocks';
import { UserIconComponent } from '../user-icon/user-icon.component';
......@@ -10,7 +12,8 @@ describe('UserProfileComponent', () => {
let component: UserProfileComponent;
let fixture: ComponentFixture<UserProfileComponent>;
const userProfileName: string = '[data-test-class="user-profile-name"';
const userProfileName: string = getDataTestClassOf('user-profile-name');
const userProfileNameUnknown: string = getDataTestClassOf('user-profile-name-unknown');
beforeEach(async () => {
await TestBed.configureTestingModule({
......@@ -49,4 +52,19 @@ describe('UserProfileComponent', () => {
expect((<HTMLElement>element).innerHTML).toContain(userProfile.firstName + ' ' + userProfile.lastName);
})
})
describe('if user profile NOT exists', () => {
beforeEach(() => {
component.userProfileStateResource = createErrorStateResource(createApiError());
fixture.detectChanges();
})
it('show user name unknown as "Unbekannter Benutzer"', () => {
const element = fixture.nativeElement.querySelector(userProfileNameUnknown);
expect(element).toBeInstanceOf(HTMLElement);
expect((<HTMLElement>element).innerHTML).toContain('Unbekannter Benutzer');
})
})
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment