Commit e3656f50 authored by François Agneray's avatar François Agneray
Browse files

Fixed tests => done

parent 3f084a97
import { Action } from '@ngrx/store';
import { UserProfile } from './user-profile.model';
export const LOGIN = '[Auth] Login';
export const LOGOUT = '[Auth] Logout';
export const AUTH_SUCCESS = '[Auth] Auth Success';
......@@ -27,7 +29,7 @@ export class AuthSuccessAction implements Action {
export class LoadUserProfileSuccessAction implements Action {
readonly type = LOAD_USER_PROFILE_SUCCESS;
constructor(public payload: Keycloak.KeycloakProfile) { }
constructor(public payload: UserProfile) { }
}
export class OpenEditProfileAction implements Action {
......
export interface UserProfile {
id?: string;
username?: string;
email?: string;
firstName?: string;
lastName?: string;
enabled?: boolean;
emailVerified?: boolean;
totp?: boolean;
createdTimestamp?: number;
}
\ No newline at end of file
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
import { Instance } from '../../metamodel/model';
import { UserProfile } from '../../auth/store/user-profile.model';
import { environment } from '../../../environments/environment'
@Component({
......@@ -11,7 +12,7 @@ import { environment } from '../../../environments/environment'
})
export class NavComponent {
@Input() isAuthenticated: boolean;
@Input() userProfile: Keycloak.KeycloakProfile;
@Input() userProfile: UserProfile;
@Input() instance: Instance;
@Output() login: EventEmitter<any> = new EventEmitter();
@Output() logout: EventEmitter<any> = new EventEmitter();
......
......@@ -3,11 +3,10 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { provideMockStore, MockStore } from '@ngrx/store/testing';
import * as fromAuth from '../../auth/store/auth.reducer';
import * as authActions from '../../auth/store/auth.action';
import { UserProfile } from '../../auth/store/user-profile.model';
import { AppComponent } from './app.component';
import * as fromLogin from '../../login/store/login.reducer';
import * as loginActions from '../../login/store/login.action';
import { LoginToken } from '../../login/store/model';
import * as fromMetamodel from '../../metamodel/reducers';
import * as instanceActions from '../../metamodel/action/instance.action';
......@@ -15,14 +14,14 @@ describe('[Core] Container: AppComponent', () => {
@Component({ selector: 'app-nav', template: '' })
class NavStubComponent {
@Input() isAuthenticated: boolean;
@Input() loginToken: LoginToken;
@Input() userProfile: UserProfile;
}
let component: AppComponent;
let fixture: ComponentFixture<AppComponent>;
let store: MockStore;
const initialState = {
login: { ...fromLogin.initialState },
auth: { ...fromAuth.initialState },
metamodel: { ...fromMetamodel }
};
......@@ -47,17 +46,15 @@ describe('[Core] Container: AppComponent', () => {
});
it('should execute ngOnInit lifecycle', () => {
const loginLocalStorageAction = new loginActions.LoginLocalStorageAction();
const loadInstanceMetaAction = new instanceActions.LoadInstanceMetaAction();
const spy = spyOn(store, 'dispatch');
component.ngOnInit();
expect(spy).toHaveBeenCalledTimes(2);
expect(spy).toHaveBeenCalledWith(loginLocalStorageAction);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(loadInstanceMetaAction);
});
it('#logout() should dispatch LogoutAction', () => {
const logoutAction = new loginActions.LogoutAction();
const logoutAction = new authActions.LogoutAction();
const spy = spyOn(store, 'dispatch');
component.logout();
expect(spy).toHaveBeenCalledTimes(1);
......
......@@ -9,6 +9,7 @@ import * as metamodelSelector from '../../metamodel/selectors';
import * as fromAuth from '../../auth/store/auth.reducer';
import * as authActions from '../../auth/store/auth.action';
import * as authSelector from '../../auth/store/auth.selector';
import { UserProfile } from '../../auth/store/user-profile.model';
import { Instance } from '../../metamodel/model';
import { VERSIONS } from '../../../settings/settings';
......@@ -27,7 +28,7 @@ export class AppComponent implements OnInit {
public anisClientVersion: string = VERSIONS.anisClient;
public year = (new Date()).getFullYear();
public isAuthenticated: Observable<boolean>;
public userProfile: Observable<Keycloak.KeycloakProfile>
public userProfile: Observable<UserProfile>
public instance: Observable<Instance>;
constructor(private store: Store<StoreState>) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment