-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
AngularRepository.spec.ts
78 lines (65 loc) · 3.51 KB
/
AngularRepository.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { stubAxiosHttp } from '../../../http/AxiosHttpStub';
import { Project } from '@/springboot/domain/Project';
import { createProject } from '../../domain/Project.fixture';
import { RestProject, toRestProject } from '@/springboot/secondary/RestProject';
import AngularRepository from '@/springboot/secondary/client/AngularRepository';
import { stubProjectHistoryService } from '../../../common/domain/ProjectHistoryService.fixture';
const PROJECT_FOLDER = 'folder/path';
describe('AngularRepository', () => {
it('should add Angular', async () => {
const projectHistoryService = stubProjectHistoryService();
const axiosHttpStub = stubAxiosHttp();
axiosHttpStub.post.resolves();
const angularRepository = new AngularRepository(axiosHttpStub, projectHistoryService);
const project: Project = createProject({ folder: PROJECT_FOLDER });
await angularRepository.add(project);
const expectedRestProject: RestProject = toRestProject(project);
const [uri, payload] = axiosHttpStub.post.getCall(0).args;
expect(uri).toBe('/api/clients/angular');
expect(payload).toEqual<RestProject>(expectedRestProject);
const [projectFolder] = projectHistoryService.get.getCall(0).args;
expect(projectFolder).toBe(PROJECT_FOLDER);
});
it('should add Angular with JWT', async () => {
const projectHistoryService = stubProjectHistoryService();
const axiosHttpStub = stubAxiosHttp();
axiosHttpStub.post.resolves();
const angularRepository = new AngularRepository(axiosHttpStub, projectHistoryService);
const project: Project = createProject({ folder: PROJECT_FOLDER });
await angularRepository.addWithJWT(project);
const expectedRestProject: RestProject = toRestProject(project);
const [uri, payload] = axiosHttpStub.post.getCall(0).args;
expect(uri).toBe('/api/clients/angular/jwt');
expect(payload).toEqual<RestProject>(expectedRestProject);
const [projectFolder] = projectHistoryService.get.getCall(0).args;
expect(projectFolder).toBe(PROJECT_FOLDER);
});
it('should add Oauth2', async () => {
const projectHistoryService = stubProjectHistoryService();
const axiosHttpStub = stubAxiosHttp();
axiosHttpStub.post.resolves();
const angularRepository = new AngularRepository(axiosHttpStub, projectHistoryService);
const project: Project = createProject({ folder: PROJECT_FOLDER });
await angularRepository.addOauth2(project);
const expectedRestProject: RestProject = toRestProject(project);
const [uri, payload] = axiosHttpStub.post.getCall(0).args;
expect(uri).toBe('/api/clients/angular/oauth2');
expect(payload).toEqual<RestProject>(expectedRestProject);
const [projectFolder] = projectHistoryService.get.getCall(0).args;
expect(projectFolder).toBe(PROJECT_FOLDER);
});
it('should add Health', async () => {
const projectHistoryService = stubProjectHistoryService();
const axiosHttpStub = stubAxiosHttp();
axiosHttpStub.post.resolves();
const angularRepository = new AngularRepository(axiosHttpStub, projectHistoryService);
const project: Project = createProject({ folder: PROJECT_FOLDER });
await angularRepository.addHealth(project);
const expectedRestProject: RestProject = toRestProject(project);
const [uri, payload] = axiosHttpStub.post.getCall(0).args;
expect(uri).toBe('/api/clients/angular/admin-pages/health');
expect(payload).toEqual<RestProject>(expectedRestProject);
const [projectFolder] = projectHistoryService.get.getCall(0).args;
expect(projectFolder).toBe(PROJECT_FOLDER);
});
});