Skip to content

Commit 872952e

Browse files
fix: TT-155 resolve comments & fix user.selectors.spec
1 parent 29e1b27 commit 872952e

File tree

7 files changed

+29
-37
lines changed

7 files changed

+29
-37
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ testem.log
4343
.keys.json
4444
keys.ts
4545
src/environments/keys.ts
46+
debug.log
4647

4748
# System Files
4849
.DS_Store

debug.log

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/app/modules/shared/components/user/user.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
33

4-
54
@Component({
65
selector: 'app-user',
76
templateUrl: './user.component.html',

src/app/modules/user/models/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export interface User {
22
name: string;
33
email: string;
4-
roles?: string[];
4+
roles?: string[];
55
groups?: string[];
66
id: string;
77
tenant_id?: string;
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Injectable } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
3-
43
import { Observable } from 'rxjs';
54
import { environment } from 'src/environments/environment';
5+
import { User } from '../models/user';
66

77
@Injectable({
88
providedIn: 'root',
@@ -14,8 +14,7 @@ export class UserService {
1414

1515
baseUrl = `${environment.timeTrackerApiUrl}/users`;
1616

17-
loadUser(userId): Observable<any> {
18-
return this.http.get(`${this.baseUrl}/${userId}`);
17+
loadUser(userId: string): Observable<User> {
18+
return this.http.get<User>(`${this.baseUrl}/${userId}`);
1919
}
20-
2120
}

src/app/modules/user/store/user.reducer.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import { LoadUser, LoadUserFail, LoadUserSuccess } from './user.actions';
33
import { User } from '../models/user';
44

55
describe('userReducer', () => {
6-
const initState = {
6+
const initialState = {
77
name: '',
88
email: '',
99
roles: [],
1010
groups: [],
11-
}
11+
};
1212

13-
it('on LoadUser, state equal to initState', () => {
13+
it('on LoadUser, state equal to initialState', () => {
1414
const userId = 'dummy_id_load';
1515
const action = new LoadUser(userId);
16-
const state = userReducer(initState, action);
16+
const state = userReducer(initialState, action);
1717

18-
expect(state).toEqual(initState);
18+
expect(state).toEqual(initialState);
1919
});
2020

2121
it('on LoadUserSuccess, userFound is saved in store', () => {
@@ -30,15 +30,15 @@ describe('userReducer', () => {
3030
};
3131

3232
const action = new LoadUserSuccess(userFound);
33-
const state = userReducer(initState, action);
33+
const state = userReducer(initialState, action);
3434

3535
expect(state).toEqual(userFound);
3636
});
3737

38-
it('on LoadUserFail, state equal to initState', () => {
38+
it('on LoadUserFail, state equal to initialState', () => {
3939
const action = new LoadUserFail('error');
40-
const state = userReducer(initState, action);
40+
const state = userReducer(initialState, action);
4141

42-
expect(state).toEqual(initState);
42+
expect(state).toEqual(initialState);
4343
});
4444
});
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import { getUserInfo } from './user.selectors';
1+
import { getUserGroups, getUserInfo } from './user.selectors';
22
import { User } from '../models/user';
33

44
describe('UserSelectors', () => {
5-
const userInfo: User = {
6-
name: 'Unknown Name',
7-
8-
roles: [],
9-
groups: [],
10-
id: 'dummy_tenant_id_load',
11-
tenant_id: null,
12-
deleted: null
13-
};
5+
const userState: User = {
6+
name: 'Unknown Name',
7+
8+
roles: [],
9+
groups: [],
10+
id: 'dummy_tenant_id_load',
11+
tenant_id: null,
12+
deleted: null,
13+
};
1414

15-
it('should select user info', () => {
16-
const result = getUserInfo.projector(userInfo);
17-
18-
expect(userInfo.email).toEqual('[email protected]');
15+
it('should select user from store', () => {
16+
expect(getUserInfo.projector(userState)).toEqual(userState);
1917
});
2018

19+
it('should select user groups from store', () => {
20+
expect(getUserGroups.projector(userState)).toEqual(userState.groups);
21+
});
2122
});

0 commit comments

Comments
 (0)