Skip to content
Snippets Groups Projects
Commit 116a73db authored by Alexander Reifschneider's avatar Alexander Reifschneider
Browse files

Fix unit-tests "init users"

parent 3c695613
Branches
Tags
1 merge request!26Fix e2e tests
......@@ -32,6 +32,7 @@ import {
import { getElementFromFixture } from '@alfa-client/test-utils';
import { SpinnerComponent } from '@alfa-client/ui';
import { NO_NAME_MESSAGE, UserProfileResource, userProfileMessage } from '@alfa-client/user-profile-shared';
import { SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatIcon } from '@angular/material/icon';
import { faker } from '@faker-js/faker';
......@@ -119,6 +120,27 @@ describe('UserIconComponent', () => {
});
});
describe('ngOnChanges', () => {
const userProfileChange: SimpleChange = new SimpleChange(1, 2, true);
it('should get tooltip', () => {
component.getTooltip = jest.fn();
component.ngOnChanges({ userProfileStateResource: userProfileChange });
expect(component.getTooltip).toHaveBeenCalled();
});
it('should not get tooltip', () => {
component.getTooltip = jest.fn();
component.withTooltip = false;
component.ngOnChanges({ userProfileStateResource: userProfileChange });
expect(component.getTooltip).not.toHaveBeenCalled();
});
});
describe('tooltip', () => {
it('should return user name', () => {
component.userProfileStateResource = createStateResource(userProfile);
......
......@@ -32,13 +32,14 @@ import { isUndefined } from 'lodash-es';
})
export class UserIconComponent {
@Input() userProfileStateResource: StateResource<UserProfileResource> = createEmptyStateResource<UserProfileResource>();
@Input() withTooltip: boolean = true;
readonly messageCode = MessageCode;
tooltip: string;
ngOnChanges(changes: SimpleChanges): void {
if (changes.userProfileStateResource) {
if (changes.userProfileStateResource && this.withTooltip) {
this.tooltip = this.getTooltip();
}
}
......
......@@ -33,6 +33,7 @@
button-content
data-test-id="user-icon"
[userProfileStateResource]="currentUserResource"
[withTooltip]="false"
class="user-profile-icon"
>
</alfa-user-icon>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment