Revize d2799ca5
Přidáno uživatelem Jakub Danek před více než 5 roky(ů)
webapp/src/app/services/tests/user.service.spec.ts | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import {UserService} from '../api/user.service'; |
4 | 4 |
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; |
5 |
import {Languages, RequestStatus, UserType, VacationType} from '../../enums/common.enum';
|
|
5 |
import {RequestStatus, VacationType} from '../../enums/common.enum';
|
|
6 | 6 |
import {environment} from '../../../environments/environment'; |
7 | 7 |
|
8 | 8 |
describe('UsersService', () => { |
... | ... | |
21 | 21 |
}); |
22 | 22 |
afterEach(() => httpMock.verify()); |
23 | 23 |
|
24 |
it('getLoggedUser', () => { |
|
25 |
const dummyData = { |
|
26 |
id: 1, |
|
27 |
firstName: 'Tomas', |
|
28 |
lastName: 'Novak', |
|
29 |
photo: 'https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg', |
|
30 |
vacationCount: 8.5, |
|
31 |
sickDayCount: 3, |
|
32 |
status: 'ACCEPTED', |
|
33 |
role: 'EMPLOYER', |
|
34 |
notification: '2000/12/01 09:00:00' |
|
35 |
}; |
|
36 |
|
|
37 |
|
|
38 |
service.getLoggedUserProfile().subscribe((data: any) => { |
|
39 |
expect(data.id).toBe(1); |
|
40 |
expect(data.vacationCount).toBe(8.5); |
|
41 |
expect(data.sickDayCount).toBe(3); |
|
42 |
expect(data.status).toBe(RequestStatus.ACCEPTED); |
|
43 |
expect(data.role).toBe(UserType.EMPLOYER); |
|
44 |
expect(data.notification).toBeDefined(); |
|
45 |
}); |
|
46 |
|
|
47 |
const req = httpMock.expectOne(baseUrl + '/api/user/me/profile'); |
|
48 |
expect(req.request.method).toBe('GET'); |
|
49 |
req.flush(dummyData); |
|
50 |
}); |
|
51 |
|
|
52 |
it('getLoggedUserWithLanguage', () => { |
|
53 |
const dummyData = { |
|
54 |
id: 1, |
|
55 |
firstName: 'Tomas', |
|
56 |
lastName: 'Novak', |
|
57 |
photo: 'https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg', |
|
58 |
vacationCount: 8.5, |
|
59 |
sickDayCount: 3, |
|
60 |
status: 'ACCEPTED', |
|
61 |
role: 'EMPLOYER', |
|
62 |
notification: '2000/12/01 09:00:00' |
|
63 |
}; |
|
64 |
|
|
65 |
|
|
66 |
service.getLoggedUserProfileWithLanguage(Languages.ENGLISH).subscribe((data: any) => { |
|
67 |
expect(data.id).toBe(1); |
|
68 |
expect(data.vacationCount).toBe(8.5); |
|
69 |
expect(data.sickDayCount).toBe(3); |
|
70 |
expect(data.status).toBe(RequestStatus.ACCEPTED); |
|
71 |
expect(data.role).toBe(UserType.EMPLOYER); |
|
72 |
expect(data.notification).toBeDefined(); |
|
73 |
}); |
|
74 |
|
|
75 |
const req = httpMock.expectOne(baseUrl + '/api/user/me/profile?lang=EN'); |
|
76 |
expect(req.request.method).toBe('GET'); |
|
77 |
req.flush(dummyData); |
|
78 |
}); |
|
79 |
|
|
80 | 24 |
it('getLoggedUserCalendar', () => { |
81 | 25 |
const dummyData = [ |
82 | 26 |
{id: 1, date: '2000/10/10', from: '09:00', to: '13:00', type: 'VACATION'}, |
Také k dispozici: Unified diff
re #37 make UI compatible with new User controller API