@ieeesa-npm/tenants 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +31 -0
- package/ng-package.json +8 -0
- package/package.json +12 -25
- package/src/lib/assets/constants.json +454 -0
- package/src/lib/assets/tenant-validations.ts +18 -0
- package/src/lib/assets/tenants-mock.ts +1240 -0
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.html +15 -0
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.scss +44 -0
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.spec.ts +574 -0
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.ts +602 -0
- package/src/lib/components/create-modify-role/create-modify-role.component.html +15 -0
- package/src/lib/components/create-modify-role/create-modify-role.component.scss +83 -0
- package/src/lib/components/create-modify-role/create-modify-role.component.spec.ts +346 -0
- package/src/lib/components/create-modify-role/create-modify-role.component.ts +321 -0
- package/src/lib/components/create-tenant-application/create-tenant-application.component.html +18 -0
- package/src/lib/components/create-tenant-application/create-tenant-application.component.scss +73 -0
- package/src/lib/components/create-tenant-application/create-tenant-application.component.spec.ts +775 -0
- package/src/lib/components/create-tenant-application/create-tenant-application.component.ts +638 -0
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.html +22 -0
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.scss +79 -0
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.spec.ts +716 -0
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.ts +504 -0
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.html +44 -0
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.scss +16 -0
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.spec.ts +115 -0
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.ts +109 -0
- package/src/lib/components/view-tenant-details/view-tenant-details.component.html +195 -0
- package/src/lib/components/view-tenant-details/view-tenant-details.component.scss +163 -0
- package/src/lib/components/view-tenant-details/view-tenant-details.component.spec.ts +1221 -0
- package/src/lib/components/view-tenant-details/view-tenant-details.component.ts +876 -0
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.html +10 -0
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.scss +44 -0
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.spec.ts +410 -0
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.ts +219 -0
- package/src/lib/components/view-tenants-list/view-tenants-list.component.html +32 -0
- package/src/lib/components/view-tenants-list/view-tenants-list.component.scss +35 -0
- package/src/lib/components/view-tenants-list/view-tenants-list.component.spec.ts +464 -0
- package/src/lib/components/view-tenants-list/view-tenants-list.component.ts +388 -0
- package/src/lib/models/app-type-config.model.ts +14 -0
- package/src/lib/models/app-type.model.ts +5 -0
- package/src/lib/models/create-group-type-config.model.ts +18 -0
- package/src/lib/models/create-group-type.model.ts +46 -0
- package/src/lib/models/feature-permission-id.model.ts +6 -0
- package/src/lib/models/features.model.ts +15 -0
- package/src/lib/models/form-status.model.ts +5 -0
- package/src/lib/models/permission-type.model.ts +9 -0
- package/src/lib/models/role-menu-action.model.ts +5 -0
- package/src/lib/models/role-type.model.ts +34 -0
- package/src/lib/models/roles-and-permissions-table-type.model.ts +5 -0
- package/src/lib/models/roles-and-permissions.model.ts +113 -0
- package/src/lib/models/route-config.model.ts +4 -0
- package/src/lib/models/table-column-schema-view-tenant-list.model.ts +21 -0
- package/src/lib/models/tenant-function-type.model.ts +10 -0
- package/src/lib/models/tenant.model.ts +47 -0
- package/src/lib/models/tenants-permission.model.ts +9 -0
- package/src/lib/models/update-tenant-status.model.ts +12 -0
- package/src/lib/models/view-tenant-group-types.model.ts +34 -0
- package/src/lib/services/tenant-applications.service.spec.ts +1245 -0
- package/src/lib/services/tenant-applications.service.ts +798 -0
- package/src/lib/services/tenant-permissions-map.service.spec.ts +25 -0
- package/src/lib/services/tenant-permissions-map.service.ts +28 -0
- package/src/lib/services/tenant-permissions.service.spec.ts +62 -0
- package/src/lib/services/tenant-permissions.service.ts +49 -0
- package/src/lib/tenant-applications.component.html +0 -0
- package/src/lib/tenant-applications.component.scss +0 -0
- package/src/lib/tenant-applications.component.spec.ts +28 -0
- package/src/lib/tenant-applications.component.ts +12 -0
- package/src/lib/tenant-applications.module.ts +8 -0
- package/{public-api.d.ts → src/public-api.ts} +40 -30
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2022/ieeesa-npm-tenants.mjs +0 -5
- package/esm2022/lib/assets/constants.json +0 -390
- package/esm2022/lib/assets/tenant-validations.mjs +0 -13
- package/esm2022/lib/components/create-modify-role/create-modify-role.component.mjs +0 -280
- package/esm2022/lib/components/create-tenant-application/create-tenant-application.component.mjs +0 -512
- package/esm2022/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.mjs +0 -391
- package/esm2022/lib/components/tenant-basic-details/tenant-basic-details.component.mjs +0 -95
- package/esm2022/lib/components/view-tenant-details/view-tenant-details.component.mjs +0 -708
- package/esm2022/lib/components/view-tenant-group-types/view-tenant-group-types.component.mjs +0 -174
- package/esm2022/lib/components/view-tenants-list/view-tenants-list.component.mjs +0 -334
- package/esm2022/lib/models/app-type-config.model.mjs +0 -2
- package/esm2022/lib/models/app-type.model.mjs +0 -7
- package/esm2022/lib/models/feature-permission-id.model.mjs +0 -8
- package/esm2022/lib/models/features.model.mjs +0 -2
- package/esm2022/lib/models/form-status.model.mjs +0 -7
- package/esm2022/lib/models/permission-type.model.mjs +0 -12
- package/esm2022/lib/models/role-menu-action.model.mjs +0 -7
- package/esm2022/lib/models/role-type.model.mjs +0 -2
- package/esm2022/lib/models/roles-and-permissions-table-type.model.mjs +0 -7
- package/esm2022/lib/models/roles-and-permissions.model.mjs +0 -2
- package/esm2022/lib/models/route-config.model.mjs +0 -2
- package/esm2022/lib/models/table-column-schema-view-tenant-list.model.mjs +0 -16
- package/esm2022/lib/models/tenant-function-type.model.mjs +0 -10
- package/esm2022/lib/models/tenant.model.mjs +0 -2
- package/esm2022/lib/models/tenants-permission.model.mjs +0 -2
- package/esm2022/lib/models/update-tenant-status.model.mjs +0 -2
- package/esm2022/lib/models/view-tenant-group-types.model.mjs +0 -9
- package/esm2022/lib/services/tenant-applications.service.mjs +0 -542
- package/esm2022/lib/services/tenant-permissions-map.service.mjs +0 -36
- package/esm2022/lib/services/tenant-permissions.service.mjs +0 -38
- package/esm2022/lib/tenant-applications.component.mjs +0 -14
- package/esm2022/lib/tenant-applications.module.mjs +0 -16
- package/esm2022/public-api.mjs +0 -34
- package/fesm2022/ieeesa-npm-tenants.mjs +0 -3565
- package/fesm2022/ieeesa-npm-tenants.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/assets/tenant-validations.d.ts +0 -11
- package/lib/components/create-modify-role/create-modify-role.component.d.ts +0 -103
- package/lib/components/create-tenant-application/create-tenant-application.component.d.ts +0 -128
- package/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.d.ts +0 -106
- package/lib/components/tenant-basic-details/tenant-basic-details.component.d.ts +0 -408
- package/lib/components/view-tenant-details/view-tenant-details.component.d.ts +0 -216
- package/lib/components/view-tenant-group-types/view-tenant-group-types.component.d.ts +0 -58
- package/lib/components/view-tenants-list/view-tenants-list.component.d.ts +0 -134
- package/lib/models/app-type-config.model.d.ts +0 -14
- package/lib/models/app-type.model.d.ts +0 -4
- package/lib/models/feature-permission-id.model.d.ts +0 -4
- package/lib/models/features.model.d.ts +0 -15
- package/lib/models/form-status.model.d.ts +0 -4
- package/lib/models/permission-type.model.d.ts +0 -8
- package/lib/models/role-menu-action.model.d.ts +0 -4
- package/lib/models/role-type.model.d.ts +0 -27
- package/lib/models/roles-and-permissions-table-type.model.d.ts +0 -4
- package/lib/models/roles-and-permissions.model.d.ts +0 -119
- package/lib/models/route-config.model.d.ts +0 -4
- package/lib/models/table-column-schema-view-tenant-list.model.d.ts +0 -20
- package/lib/models/tenant-function-type.model.d.ts +0 -7
- package/lib/models/tenant.model.d.ts +0 -51
- package/lib/models/tenants-permission.model.d.ts +0 -9
- package/lib/models/update-tenant-status.model.d.ts +0 -14
- package/lib/models/view-tenant-group-types.model.d.ts +0 -27
- package/lib/services/tenant-applications.service.d.ts +0 -357
- package/lib/services/tenant-permissions-map.service.d.ts +0 -13
- package/lib/services/tenant-permissions.service.d.ts +0 -22
- package/lib/tenant-applications.component.d.ts +0 -5
- package/lib/tenant-applications.module.d.ts +0 -6
|
@@ -0,0 +1,1245 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { TenantApplicationsService } from './tenant-applications.service';
|
|
3
|
+
import { AlertsService, HttpService } from '@ieeesa-npm/utility';
|
|
4
|
+
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
|
5
|
+
import {
|
|
6
|
+
HttpClient,
|
|
7
|
+
HttpErrorResponse,
|
|
8
|
+
HttpHandler,
|
|
9
|
+
} from '@angular/common/http';
|
|
10
|
+
import { of, throwError } from 'rxjs';
|
|
11
|
+
import { TenantsMocks } from '../assets/tenants-mock';
|
|
12
|
+
import { Features } from '../models/features.model';
|
|
13
|
+
import { AppTypeConfig } from '../models/app-type-config.model';
|
|
14
|
+
import { RoleTypeConfiguration } from '../models/role-type.model';
|
|
15
|
+
import {
|
|
16
|
+
RolesAndPermissionsRequestPayload,
|
|
17
|
+
RolePermissionMappingRequestPayload,
|
|
18
|
+
} from '../models/roles-and-permissions.model';
|
|
19
|
+
|
|
20
|
+
describe('TenantApplicationsService', () => {
|
|
21
|
+
let service: TenantApplicationsService;
|
|
22
|
+
let httpService: HttpService;
|
|
23
|
+
const getFeaturesListMockResponse = TenantsMocks.mockFeatureResponse;
|
|
24
|
+
const getAppTypesMockResponse = TenantsMocks.mockAppTypesResponse;
|
|
25
|
+
const createTenantMockPayload = TenantsMocks.createTenantMockPayload;
|
|
26
|
+
const mockErrorResponse = {
|
|
27
|
+
error: 'Test error',
|
|
28
|
+
status: 500,
|
|
29
|
+
statusText: 'Internal server error',
|
|
30
|
+
};
|
|
31
|
+
const createTenantMockResponse = TenantsMocks.createTenantMockResponse;
|
|
32
|
+
const updateTenantStatusMockResponse =
|
|
33
|
+
TenantsMocks.updateTenantStatusMockResponse;
|
|
34
|
+
const updateTenantStatusMockPayload =
|
|
35
|
+
TenantsMocks.updateTenantStatusMockPayload;
|
|
36
|
+
const getRoleTypesMockResponse = TenantsMocks.mockRoleTypesResponse;
|
|
37
|
+
const getRoleTypeMockPayload = TenantsMocks.mockRoleTypePayload;
|
|
38
|
+
const createRoleMockResponse = TenantsMocks.createRoleMockResponse;
|
|
39
|
+
const createRoleMockPayload = TenantsMocks.createRoleMockPayload;
|
|
40
|
+
const editRoleMockResponse = TenantsMocks.editRoleMockResponse;
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
TestBed.configureTestingModule({
|
|
43
|
+
imports: [HttpClientTestingModule],
|
|
44
|
+
providers: [
|
|
45
|
+
HttpClient,
|
|
46
|
+
HttpHandler,
|
|
47
|
+
HttpService,
|
|
48
|
+
TenantApplicationsService,
|
|
49
|
+
AlertsService,
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
service = TestBed.inject(TenantApplicationsService);
|
|
53
|
+
httpService = TestBed.inject(HttpService);
|
|
54
|
+
service.checkBoxOptions = TenantsMocks?.mockFeaturesFormattedResponse;
|
|
55
|
+
});
|
|
56
|
+
describe('#setAppConfig', () => {
|
|
57
|
+
it('should set app config', () => {
|
|
58
|
+
const spyOnSetAppConfig = spyOn(
|
|
59
|
+
service,
|
|
60
|
+
'setAppConfig'
|
|
61
|
+
).and.callThrough();
|
|
62
|
+
service.setAppConfig(
|
|
63
|
+
TenantsMocks?.getApiBaseURL,
|
|
64
|
+
TenantsMocks?.mockUserPermissions
|
|
65
|
+
);
|
|
66
|
+
expect(spyOnSetAppConfig).toHaveBeenCalledWith(
|
|
67
|
+
TenantsMocks?.getApiBaseURL,
|
|
68
|
+
TenantsMocks?.mockUserPermissions
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe('#setUserTenantsPermissions', () => {
|
|
73
|
+
it('should call setUserTenantsPermissions method and set setUserTenantsPermissions', () => {
|
|
74
|
+
const setUserTenantsPermissionsSpy = spyOn(
|
|
75
|
+
service,
|
|
76
|
+
'setUserTenantsPermissions'
|
|
77
|
+
).and.callThrough();
|
|
78
|
+
service.setUserTenantsPermissions(
|
|
79
|
+
TenantsMocks.mockGlobalTenantsPermissions
|
|
80
|
+
);
|
|
81
|
+
expect(setUserTenantsPermissionsSpy).toHaveBeenCalledWith(
|
|
82
|
+
TenantsMocks.mockGlobalTenantsPermissions
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
describe('#getUserTenantsPermissions', () => {
|
|
87
|
+
it('should return user tenants permissions', () => {
|
|
88
|
+
service.setUserTenantsPermissions(
|
|
89
|
+
TenantsMocks.mockGlobalTenantsPermissions
|
|
90
|
+
);
|
|
91
|
+
expect(service.getUserTenantsPermissions()).toEqual(
|
|
92
|
+
TenantsMocks.mockGlobalTenantsPermissions
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('#getTenantsList', () => {
|
|
97
|
+
it('should call getTenantsList', () => {
|
|
98
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
99
|
+
of(TenantsMocks.getTenantsMockResponse)
|
|
100
|
+
);
|
|
101
|
+
service
|
|
102
|
+
.getTenantsList(TenantsMocks.getTenantsMockPayload)
|
|
103
|
+
.subscribe((response) => {
|
|
104
|
+
expect(response).toEqual(TenantsMocks.getTenantsMockResponse);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
it('should return error in retrieving tenants list', (done) => {
|
|
108
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
109
|
+
throwError(() => new HttpErrorResponse(TenantsMocks.mockErrorResponse))
|
|
110
|
+
);
|
|
111
|
+
service.getTenantsList(TenantsMocks.getTenantsMockPayload).subscribe({
|
|
112
|
+
next: () => {
|
|
113
|
+
done();
|
|
114
|
+
},
|
|
115
|
+
error: (error: HttpErrorResponse) => {
|
|
116
|
+
done();
|
|
117
|
+
expect(error).toBeTruthy();
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('#getRolesAndPermissions', () => {
|
|
124
|
+
it('should get roles and permissions mappings configured for the tenant', () => {
|
|
125
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
126
|
+
of(TenantsMocks.mockUserPermissionRoles)
|
|
127
|
+
);
|
|
128
|
+
service
|
|
129
|
+
.getRolesAndPermissionsMappings(
|
|
130
|
+
'SAAPS',
|
|
131
|
+
TenantsMocks.getRolesMockPayload
|
|
132
|
+
)
|
|
133
|
+
.subscribe((response) => {
|
|
134
|
+
expect(response).toEqual(TenantsMocks.mockUserPermissionRoles);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
it('should return error in retrieving roles and permissions list', (done) => {
|
|
138
|
+
const mockRolesAndPermissionsMappingErrorResponse = {
|
|
139
|
+
error: {
|
|
140
|
+
status: false,
|
|
141
|
+
message: 'Unable to fetch Roles and Permissions Mapping.',
|
|
142
|
+
body: { errorCodes: ['3009'] },
|
|
143
|
+
},
|
|
144
|
+
status: 400,
|
|
145
|
+
statusText: 'OK',
|
|
146
|
+
};
|
|
147
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
148
|
+
throwError(
|
|
149
|
+
() =>
|
|
150
|
+
new HttpErrorResponse(mockRolesAndPermissionsMappingErrorResponse)
|
|
151
|
+
)
|
|
152
|
+
);
|
|
153
|
+
service
|
|
154
|
+
.getRolesAndPermissionsMappings(
|
|
155
|
+
'SAAPS',
|
|
156
|
+
TenantsMocks.getRolesMockPayload
|
|
157
|
+
)
|
|
158
|
+
.subscribe({
|
|
159
|
+
next: () => {
|
|
160
|
+
done();
|
|
161
|
+
},
|
|
162
|
+
error: (error: HttpErrorResponse) => {
|
|
163
|
+
done();
|
|
164
|
+
expect(error).toBeTruthy();
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe('#getRoles', () => {
|
|
171
|
+
it('should get the roles configured for the tenant', () => {
|
|
172
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
173
|
+
of(TenantsMocks.mockUserRoles)
|
|
174
|
+
);
|
|
175
|
+
service.getRoles('SAAPS').subscribe((response) => {
|
|
176
|
+
expect(response).toEqual(TenantsMocks.mockUserRoles);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
it('should return error in retrieving roles list', (done) => {
|
|
180
|
+
const mockRolesErrorResponse = {
|
|
181
|
+
error: {
|
|
182
|
+
status: false,
|
|
183
|
+
message: 'No Role(s) found.',
|
|
184
|
+
body: { errorCodes: ['3007'] },
|
|
185
|
+
},
|
|
186
|
+
status: 400,
|
|
187
|
+
statusText: 'OK',
|
|
188
|
+
};
|
|
189
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
190
|
+
throwError(() => new HttpErrorResponse(mockRolesErrorResponse))
|
|
191
|
+
);
|
|
192
|
+
service.getRoles('SAAPS').subscribe({
|
|
193
|
+
next: () => {
|
|
194
|
+
done();
|
|
195
|
+
},
|
|
196
|
+
error: (error: HttpErrorResponse) => {
|
|
197
|
+
done();
|
|
198
|
+
expect(error).toBeTruthy();
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
describe('#getRosterType', () => {
|
|
205
|
+
it('should get the roster type configured for the tenant', () => {
|
|
206
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
207
|
+
of(TenantsMocks.mockRosterTypeResponse)
|
|
208
|
+
);
|
|
209
|
+
service.getRosterType().subscribe((response) => {
|
|
210
|
+
expect(response).toEqual(TenantsMocks.mockRosterTypeResponse);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
it('should return error in retrieving roster types list', (done) => {
|
|
214
|
+
const mockRosterTypesErrorResponse = {
|
|
215
|
+
error: {
|
|
216
|
+
status: false,
|
|
217
|
+
message: 'Resource not found.',
|
|
218
|
+
body: { errorCodes: ['2066'] },
|
|
219
|
+
},
|
|
220
|
+
status: 400,
|
|
221
|
+
statusText: 'OK',
|
|
222
|
+
};
|
|
223
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
224
|
+
throwError(() => new HttpErrorResponse(mockRosterTypesErrorResponse))
|
|
225
|
+
);
|
|
226
|
+
service.getRosterType().subscribe({
|
|
227
|
+
next: () => {
|
|
228
|
+
done();
|
|
229
|
+
},
|
|
230
|
+
error: (error: HttpErrorResponse) => {
|
|
231
|
+
done();
|
|
232
|
+
expect(error).toBeTruthy();
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
describe('#getGroupTypeSettings', () => {
|
|
238
|
+
it('should get the settings configured for the tenant', () => {
|
|
239
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
240
|
+
of(TenantsMocks.mockGroupTypeSettingResponse)
|
|
241
|
+
);
|
|
242
|
+
service.getGroupTypeSettings().subscribe((response) => {
|
|
243
|
+
expect(response).toEqual(TenantsMocks.mockGroupTypeSettingResponse);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
it('should return error in retrieving roster types list', (done) => {
|
|
247
|
+
const mocGroupTypeSettingsErrorResponse = {
|
|
248
|
+
error: {
|
|
249
|
+
status: false,
|
|
250
|
+
message: 'Resource not found.',
|
|
251
|
+
body: { errorCodes: ['2066'] },
|
|
252
|
+
},
|
|
253
|
+
status: 400,
|
|
254
|
+
statusText: 'OK',
|
|
255
|
+
};
|
|
256
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
257
|
+
throwError(
|
|
258
|
+
() => new HttpErrorResponse(mocGroupTypeSettingsErrorResponse)
|
|
259
|
+
)
|
|
260
|
+
);
|
|
261
|
+
service.getGroupTypeSettings().subscribe({
|
|
262
|
+
next: () => {
|
|
263
|
+
done();
|
|
264
|
+
},
|
|
265
|
+
error: (error: HttpErrorResponse) => {
|
|
266
|
+
done();
|
|
267
|
+
expect(error).toBeTruthy();
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
describe('#getFeaturesList', () => {
|
|
273
|
+
it('should return get features list success response', () => {
|
|
274
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
275
|
+
of(getFeaturesListMockResponse)
|
|
276
|
+
);
|
|
277
|
+
service.getFeatures().subscribe((response) => {
|
|
278
|
+
expect(response).toEqual(getFeaturesListMockResponse);
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
it('should throw features not found error in retrieving list of features', (done) => {
|
|
282
|
+
const mockGetFeaturesListErrorResponse = {
|
|
283
|
+
error: {
|
|
284
|
+
status: false,
|
|
285
|
+
message: 'List of features not found.',
|
|
286
|
+
body: { errorCodes: ['2026'] },
|
|
287
|
+
},
|
|
288
|
+
status: 400,
|
|
289
|
+
statusText: 'OK',
|
|
290
|
+
};
|
|
291
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
292
|
+
throwError(
|
|
293
|
+
() => new HttpErrorResponse(mockGetFeaturesListErrorResponse)
|
|
294
|
+
)
|
|
295
|
+
);
|
|
296
|
+
service.getFeatures().subscribe({
|
|
297
|
+
next: () => {
|
|
298
|
+
done();
|
|
299
|
+
},
|
|
300
|
+
error: (error: HttpErrorResponse) => {
|
|
301
|
+
done();
|
|
302
|
+
expect(error).toEqual(
|
|
303
|
+
new HttpErrorResponse(mockGetFeaturesListErrorResponse)
|
|
304
|
+
);
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
it('should return Internal Server Error error while getting list of features', (done) => {
|
|
309
|
+
const errorResponse = { status: 500, message: 'Internal Server Error' };
|
|
310
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
311
|
+
throwError(() => errorResponse)
|
|
312
|
+
);
|
|
313
|
+
service.getFeatures().subscribe({
|
|
314
|
+
next: () => {
|
|
315
|
+
done();
|
|
316
|
+
},
|
|
317
|
+
error: (error: HttpErrorResponse) => {
|
|
318
|
+
done();
|
|
319
|
+
expect(error).toBeTruthy();
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
describe('#getApplicationTypes', () => {
|
|
326
|
+
it('should return application types success response', () => {
|
|
327
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
328
|
+
of(getAppTypesMockResponse)
|
|
329
|
+
);
|
|
330
|
+
service.getApplicationTypes().subscribe((response) => {
|
|
331
|
+
expect(response).toEqual(getAppTypesMockResponse);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
it('should throw application types not found error in retrieving application types', (done) => {
|
|
335
|
+
const mockGetAppTypesErrorResponse = {
|
|
336
|
+
error: {
|
|
337
|
+
status: false,
|
|
338
|
+
message: 'Application Type not found.',
|
|
339
|
+
body: { errorCodes: ['2003'] },
|
|
340
|
+
},
|
|
341
|
+
status: 400,
|
|
342
|
+
statusText: 'OK',
|
|
343
|
+
};
|
|
344
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
345
|
+
throwError(() => new HttpErrorResponse(mockGetAppTypesErrorResponse))
|
|
346
|
+
);
|
|
347
|
+
service.getApplicationTypes().subscribe({
|
|
348
|
+
next: () => {
|
|
349
|
+
done();
|
|
350
|
+
},
|
|
351
|
+
error: (error: HttpErrorResponse) => {
|
|
352
|
+
done();
|
|
353
|
+
expect(error).toEqual(
|
|
354
|
+
new HttpErrorResponse(mockGetAppTypesErrorResponse)
|
|
355
|
+
);
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
it('should return Internal Server Error error while getting application types', (done) => {
|
|
360
|
+
const errorResponse = { status: 500, message: 'Internal Server Error' };
|
|
361
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
362
|
+
throwError(() => errorResponse)
|
|
363
|
+
);
|
|
364
|
+
service.getApplicationTypes().subscribe({
|
|
365
|
+
next: () => {
|
|
366
|
+
done();
|
|
367
|
+
},
|
|
368
|
+
error: (error: HttpErrorResponse) => {
|
|
369
|
+
done();
|
|
370
|
+
expect(error).toBeTruthy();
|
|
371
|
+
},
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
describe('#createTenant', () => {
|
|
376
|
+
it('should create new tenant successfully', () => {
|
|
377
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
378
|
+
of(createTenantMockResponse)
|
|
379
|
+
);
|
|
380
|
+
service.createTenant(createTenantMockPayload).subscribe((response) => {
|
|
381
|
+
expect(response).toEqual(createTenantMockResponse);
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
it('should throw application title is required error while creating a tenant', (done) => {
|
|
385
|
+
const mockCreateTenantErrorResponse = {
|
|
386
|
+
error: {
|
|
387
|
+
status: false,
|
|
388
|
+
message: 'Application Title is required.',
|
|
389
|
+
body: { errorCodes: ['2028'] },
|
|
390
|
+
},
|
|
391
|
+
status: 400,
|
|
392
|
+
statusText: 'OK',
|
|
393
|
+
};
|
|
394
|
+
const mockCreateTenantPayload =
|
|
395
|
+
TenantsMocks.mockCreateTenantPayloadMissingAppTitle;
|
|
396
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
397
|
+
throwError(() => new HttpErrorResponse(mockCreateTenantErrorResponse))
|
|
398
|
+
);
|
|
399
|
+
service.createTenant(mockCreateTenantPayload).subscribe({
|
|
400
|
+
next: () => {
|
|
401
|
+
done();
|
|
402
|
+
},
|
|
403
|
+
error: (error: HttpErrorResponse) => {
|
|
404
|
+
done();
|
|
405
|
+
expect(error).toEqual(
|
|
406
|
+
new HttpErrorResponse(mockCreateTenantErrorResponse)
|
|
407
|
+
);
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
it('should handle error while creating a tenant is failed', (done) => {
|
|
412
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
413
|
+
throwError(() => new HttpErrorResponse(mockErrorResponse))
|
|
414
|
+
);
|
|
415
|
+
service.createTenant(createTenantMockPayload).subscribe({
|
|
416
|
+
next: () => {
|
|
417
|
+
done();
|
|
418
|
+
},
|
|
419
|
+
error: (error: HttpErrorResponse) => {
|
|
420
|
+
done();
|
|
421
|
+
expect(error).toBeTruthy();
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
describe('#createGroupType', () => {
|
|
427
|
+
it('should create new group type successfully', () => {
|
|
428
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
429
|
+
of(TenantsMocks.mockCreateGroupTypeSuccessResponse)
|
|
430
|
+
);
|
|
431
|
+
service
|
|
432
|
+
.createGroupType(TenantsMocks.mockCreateGroupTypePayload)
|
|
433
|
+
.subscribe((response) => {
|
|
434
|
+
expect(response).toEqual(
|
|
435
|
+
TenantsMocks.mockCreateGroupTypeSuccessResponse
|
|
436
|
+
);
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
it('should throw group type name already exists while creating a tenant', (done) => {
|
|
440
|
+
const mockCreateTenantErrorResponse = {
|
|
441
|
+
error: {
|
|
442
|
+
status: false,
|
|
443
|
+
message: 'Resource Not Found',
|
|
444
|
+
body: { errorCodes: ['2067'] },
|
|
445
|
+
},
|
|
446
|
+
status: 400,
|
|
447
|
+
statusText: 'OK',
|
|
448
|
+
};
|
|
449
|
+
const mockCreateGroupTypePayload =
|
|
450
|
+
TenantsMocks.mockCreateGroupTypePayload;
|
|
451
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
452
|
+
throwError(() => new HttpErrorResponse(mockCreateTenantErrorResponse))
|
|
453
|
+
);
|
|
454
|
+
service.createGroupType(mockCreateGroupTypePayload).subscribe({
|
|
455
|
+
next: () => {
|
|
456
|
+
done();
|
|
457
|
+
},
|
|
458
|
+
error: (error: HttpErrorResponse) => {
|
|
459
|
+
done();
|
|
460
|
+
expect(error).toEqual(
|
|
461
|
+
new HttpErrorResponse(mockCreateTenantErrorResponse)
|
|
462
|
+
);
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
describe('#getFeatureOptions', () => {
|
|
468
|
+
it('should format the feature list to checkbox options.', () => {
|
|
469
|
+
const featureList = TenantsMocks.mockFeatureResponse?.body;
|
|
470
|
+
service.getFeatureOptions(featureList);
|
|
471
|
+
expect(service.checkBoxOptions).toEqual(
|
|
472
|
+
TenantsMocks.mockFeaturesFormattedDefaultResponse
|
|
473
|
+
);
|
|
474
|
+
});
|
|
475
|
+
it('should return the empty checkbox options.', () => {
|
|
476
|
+
const featureList: Features[] = [];
|
|
477
|
+
service.getFeatureOptions(featureList);
|
|
478
|
+
expect(service.checkBoxOptions).toEqual([]);
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
describe('#getApplicationTypeOptions', () => {
|
|
482
|
+
it('should format the app type list to radio options.', () => {
|
|
483
|
+
const appTypeList = TenantsMocks.mockAppTypesResponse?.body;
|
|
484
|
+
service.getApplicationTypeOptions(appTypeList);
|
|
485
|
+
expect(service.radioOptions).toEqual(
|
|
486
|
+
TenantsMocks.mockAppTypesFormattedResponse
|
|
487
|
+
);
|
|
488
|
+
});
|
|
489
|
+
it('should return the empty radio options.', () => {
|
|
490
|
+
const featureList: AppTypeConfig[] = [];
|
|
491
|
+
service.getApplicationTypeOptions(featureList);
|
|
492
|
+
expect(service.radioOptions).toEqual([]);
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
describe('#getFeatureIds', () => {
|
|
496
|
+
it('should return the list of feature ids from the selected features.', () => {
|
|
497
|
+
const featureIds = service.getFeatureIds(
|
|
498
|
+
TenantsMocks.mockFeaturesFormattedResponse
|
|
499
|
+
);
|
|
500
|
+
expect(featureIds).toEqual(
|
|
501
|
+
TenantsMocks?.createTenantMockPayload?.payload?.features
|
|
502
|
+
);
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
describe('#setTenantInfo', () => {
|
|
506
|
+
it('should set the tenant info.', () => {
|
|
507
|
+
service.newTenantInfo = TenantsMocks?.createTenantMockPayload?.payload;
|
|
508
|
+
expect(service.getNewTenantInfo).toEqual(
|
|
509
|
+
TenantsMocks?.createTenantMockPayload?.payload
|
|
510
|
+
);
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
describe('#getTenantDetails', () => {
|
|
514
|
+
it('should return tenant details success response', () => {
|
|
515
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
516
|
+
of(TenantsMocks.viewTenantDetailsMockResponse)
|
|
517
|
+
);
|
|
518
|
+
service.getTenantDetails('SAAPS').subscribe((response) => {
|
|
519
|
+
expect(response).toEqual(TenantsMocks?.viewTenantDetailsMockResponse);
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
it('should return custom error in retrieving tenant details', (done) => {
|
|
523
|
+
const mockGetViewTenantsErrorResponse = {
|
|
524
|
+
error: {
|
|
525
|
+
status: false,
|
|
526
|
+
message: 'Tenant Details not found.',
|
|
527
|
+
body: { errorCodes: ['2050'] },
|
|
528
|
+
},
|
|
529
|
+
status: 404,
|
|
530
|
+
statusText: 'OK',
|
|
531
|
+
};
|
|
532
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
533
|
+
throwError(() => new HttpErrorResponse(mockGetViewTenantsErrorResponse))
|
|
534
|
+
);
|
|
535
|
+
service.getTenantDetails('').subscribe({
|
|
536
|
+
next: () => {
|
|
537
|
+
done();
|
|
538
|
+
},
|
|
539
|
+
error: (error: HttpErrorResponse) => {
|
|
540
|
+
done();
|
|
541
|
+
expect(error).toBeTruthy();
|
|
542
|
+
},
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
it('should return error in retrieving tenant details', (done) => {
|
|
546
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
547
|
+
throwError(
|
|
548
|
+
() => new HttpErrorResponse(TenantsMocks.viewTenantErrorResponse)
|
|
549
|
+
)
|
|
550
|
+
);
|
|
551
|
+
service.getTenantDetails('').subscribe({
|
|
552
|
+
next: () => {
|
|
553
|
+
done();
|
|
554
|
+
},
|
|
555
|
+
error: (error: HttpErrorResponse) => {
|
|
556
|
+
done();
|
|
557
|
+
expect(error).toBeTruthy();
|
|
558
|
+
},
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
describe('#updateTenantStatus', () => {
|
|
563
|
+
it('should update tenant status successfully', () => {
|
|
564
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
565
|
+
of(updateTenantStatusMockResponse)
|
|
566
|
+
);
|
|
567
|
+
service
|
|
568
|
+
.updateTenantStatus(updateTenantStatusMockPayload)
|
|
569
|
+
.subscribe((response) => {
|
|
570
|
+
expect(response).toEqual(updateTenantStatusMockResponse);
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
it('should throw a custom error while updating the status is failed.', (done) => {
|
|
574
|
+
const mockUpdateTenantStatusErrorResponse = {
|
|
575
|
+
error: {
|
|
576
|
+
status: false,
|
|
577
|
+
message: 'Application Id does not exist.',
|
|
578
|
+
body: { errorCodes: ['2041'] },
|
|
579
|
+
},
|
|
580
|
+
status: 400,
|
|
581
|
+
statusText: 'OK',
|
|
582
|
+
};
|
|
583
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
584
|
+
throwError(
|
|
585
|
+
() => new HttpErrorResponse(mockUpdateTenantStatusErrorResponse)
|
|
586
|
+
)
|
|
587
|
+
);
|
|
588
|
+
service
|
|
589
|
+
.updateTenantStatus(TenantsMocks.updateTenantStatusPayloadWithoutAppId)
|
|
590
|
+
.subscribe({
|
|
591
|
+
next: () => {
|
|
592
|
+
done();
|
|
593
|
+
},
|
|
594
|
+
error: (error: HttpErrorResponse) => {
|
|
595
|
+
done();
|
|
596
|
+
expect(error).toBeTruthy();
|
|
597
|
+
},
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
it('should handle error while updating the tenant status', (done) => {
|
|
601
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
602
|
+
throwError(() => new HttpErrorResponse(mockErrorResponse))
|
|
603
|
+
);
|
|
604
|
+
service.updateTenantStatus(updateTenantStatusMockPayload).subscribe({
|
|
605
|
+
next: () => {
|
|
606
|
+
done();
|
|
607
|
+
},
|
|
608
|
+
error: (error: HttpErrorResponse) => {
|
|
609
|
+
done();
|
|
610
|
+
expect(error).toBeTruthy();
|
|
611
|
+
},
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
describe('#editTenant', () => {
|
|
616
|
+
it('should edit tenant details successfully', () => {
|
|
617
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
618
|
+
of(TenantsMocks.editTenantMockResponse)
|
|
619
|
+
);
|
|
620
|
+
service
|
|
621
|
+
.editTenant(TenantsMocks.editTenantMockPayload)
|
|
622
|
+
.subscribe((response) => {
|
|
623
|
+
expect(response).toEqual(TenantsMocks.editTenantMockResponse);
|
|
624
|
+
});
|
|
625
|
+
});
|
|
626
|
+
it('should throw application title is required error while editing a tenant', (done) => {
|
|
627
|
+
const mockEditTenantErrorResponse = {
|
|
628
|
+
error: {
|
|
629
|
+
status: false,
|
|
630
|
+
message: 'Application Title is required.',
|
|
631
|
+
body: { errorCodes: ['2028'] },
|
|
632
|
+
},
|
|
633
|
+
status: 400,
|
|
634
|
+
statusText: 'OK',
|
|
635
|
+
};
|
|
636
|
+
const mockEditTenantPayload =
|
|
637
|
+
TenantsMocks.mockCreateTenantPayloadMissingAppTitle;
|
|
638
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
639
|
+
throwError(() => new HttpErrorResponse(mockEditTenantErrorResponse))
|
|
640
|
+
);
|
|
641
|
+
service.editTenant(mockEditTenantPayload).subscribe({
|
|
642
|
+
next: () => {
|
|
643
|
+
done();
|
|
644
|
+
},
|
|
645
|
+
error: (error: HttpErrorResponse) => {
|
|
646
|
+
done();
|
|
647
|
+
expect(error).toEqual(
|
|
648
|
+
new HttpErrorResponse(mockEditTenantErrorResponse)
|
|
649
|
+
);
|
|
650
|
+
},
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
it('should handle error while editing a tenant is failed', (done) => {
|
|
654
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
655
|
+
throwError(() => new HttpErrorResponse(mockErrorResponse))
|
|
656
|
+
);
|
|
657
|
+
service.createTenant(TenantsMocks.editTenantMockPayload).subscribe({
|
|
658
|
+
next: () => {
|
|
659
|
+
done();
|
|
660
|
+
},
|
|
661
|
+
error: (error: HttpErrorResponse) => {
|
|
662
|
+
done();
|
|
663
|
+
expect(error).toBeTruthy();
|
|
664
|
+
},
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
describe('#getFeaturesList', () => {
|
|
669
|
+
it('should format the feature list from checkbox options.', () => {
|
|
670
|
+
const featureList = TenantsMocks?.mockFeaturesFormattedResponse;
|
|
671
|
+
service.getFeaturesList(featureList);
|
|
672
|
+
expect(service.checkBoxOptions).toEqual(
|
|
673
|
+
TenantsMocks.mockFeaturesFormattedResponse
|
|
674
|
+
);
|
|
675
|
+
});
|
|
676
|
+
it('should return the feature list.', () => {
|
|
677
|
+
const featureList = TenantsMocks?.mockFeaturesFormattedResponse;
|
|
678
|
+
service.getFeaturesList(TenantsMocks?.mockFeaturesFormattedResponse);
|
|
679
|
+
expect(service.checkBoxOptions).toEqual(featureList);
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
describe('#getRoleTypes', () => {
|
|
683
|
+
it('should return role types success response', () => {
|
|
684
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
685
|
+
of(getRoleTypesMockResponse)
|
|
686
|
+
);
|
|
687
|
+
service.getRoleTypes(getRoleTypeMockPayload).subscribe((response) => {
|
|
688
|
+
expect(response).toEqual(getRoleTypesMockResponse);
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
it('should throw custom error if role typed not found while retrieving role types from http service', (done) => {
|
|
692
|
+
const mockGetRoleTypesErrorResponse = {
|
|
693
|
+
error: {
|
|
694
|
+
status: false,
|
|
695
|
+
message: 'Role Type not found.',
|
|
696
|
+
body: { errorCodes: ['3014'] },
|
|
697
|
+
},
|
|
698
|
+
status: 400,
|
|
699
|
+
statusText: 'OK',
|
|
700
|
+
};
|
|
701
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
702
|
+
throwError(() => new HttpErrorResponse(mockGetRoleTypesErrorResponse))
|
|
703
|
+
);
|
|
704
|
+
service.getRoleTypes(getRoleTypeMockPayload).subscribe({
|
|
705
|
+
next: () => {
|
|
706
|
+
done();
|
|
707
|
+
},
|
|
708
|
+
error: (error: HttpErrorResponse) => {
|
|
709
|
+
done();
|
|
710
|
+
expect(error).toEqual(
|
|
711
|
+
new HttpErrorResponse(mockGetRoleTypesErrorResponse)
|
|
712
|
+
);
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
});
|
|
716
|
+
it('should throw custom error if role type is already exists', (done) => {
|
|
717
|
+
const mockGetRoleTypesErrorResponse = {
|
|
718
|
+
error: {
|
|
719
|
+
status: false,
|
|
720
|
+
message: 'Role Type is already exists.',
|
|
721
|
+
body: { errorCodes: ['3012'] },
|
|
722
|
+
},
|
|
723
|
+
status: 400,
|
|
724
|
+
statusText: 'OK',
|
|
725
|
+
};
|
|
726
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
727
|
+
throwError(() => new HttpErrorResponse(mockGetRoleTypesErrorResponse))
|
|
728
|
+
);
|
|
729
|
+
service.getRoleTypes(getRoleTypeMockPayload).subscribe({
|
|
730
|
+
next: () => {
|
|
731
|
+
done();
|
|
732
|
+
},
|
|
733
|
+
error: (error: HttpErrorResponse) => {
|
|
734
|
+
done();
|
|
735
|
+
expect(error).toEqual(
|
|
736
|
+
new HttpErrorResponse(mockGetRoleTypesErrorResponse)
|
|
737
|
+
);
|
|
738
|
+
},
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
it('should throw custom error when role name is empty', (done) => {
|
|
742
|
+
const mockGetRoleTypesErrorResponse = {
|
|
743
|
+
error: {
|
|
744
|
+
status: false,
|
|
745
|
+
message: 'Role Name is required.',
|
|
746
|
+
body: { errorCodes: ['3016'] },
|
|
747
|
+
},
|
|
748
|
+
status: 400,
|
|
749
|
+
statusText: 'OK',
|
|
750
|
+
};
|
|
751
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
752
|
+
throwError(() => new HttpErrorResponse(mockGetRoleTypesErrorResponse))
|
|
753
|
+
);
|
|
754
|
+
service.getRoleTypes(getRoleTypeMockPayload).subscribe({
|
|
755
|
+
next: () => {
|
|
756
|
+
done();
|
|
757
|
+
},
|
|
758
|
+
error: (error: HttpErrorResponse) => {
|
|
759
|
+
done();
|
|
760
|
+
expect(error).toEqual(
|
|
761
|
+
new HttpErrorResponse(mockGetRoleTypesErrorResponse)
|
|
762
|
+
);
|
|
763
|
+
},
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
it('should return Internal Server Error error while getting role types', (done) => {
|
|
767
|
+
const errorResponse = { status: 500, message: 'Internal Server Error' };
|
|
768
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
769
|
+
throwError(() => errorResponse)
|
|
770
|
+
);
|
|
771
|
+
service.getRoleTypes(getRoleTypeMockPayload).subscribe({
|
|
772
|
+
next: () => {
|
|
773
|
+
done();
|
|
774
|
+
},
|
|
775
|
+
error: (error: HttpErrorResponse) => {
|
|
776
|
+
done();
|
|
777
|
+
expect(error).toBeTruthy();
|
|
778
|
+
},
|
|
779
|
+
});
|
|
780
|
+
});
|
|
781
|
+
});
|
|
782
|
+
describe('#getRoleTypeOptions', () => {
|
|
783
|
+
it('should format the role type list to select options.', () => {
|
|
784
|
+
const roleTypeList = TenantsMocks.mockRoleTypesResponse?.body;
|
|
785
|
+
service.getRoleTypeOptions(roleTypeList);
|
|
786
|
+
expect(service.roleTypeOptions).toEqual(
|
|
787
|
+
TenantsMocks.mockRoleTypesFormattedResponse
|
|
788
|
+
);
|
|
789
|
+
});
|
|
790
|
+
it('should return the empty role type options.', () => {
|
|
791
|
+
const roleTypeList: RoleTypeConfiguration[] = [];
|
|
792
|
+
service.getRoleTypeOptions(roleTypeList);
|
|
793
|
+
expect(service.roleTypeOptions).toEqual([]);
|
|
794
|
+
});
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
describe('#createRole', () => {
|
|
798
|
+
it('should create new role successfully', () => {
|
|
799
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
800
|
+
of(createRoleMockResponse)
|
|
801
|
+
);
|
|
802
|
+
service.createRole(createRoleMockPayload).subscribe((response) => {
|
|
803
|
+
expect(response).toEqual(createRoleMockResponse);
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
it('should throw custom error for creating a new role when role type is empty', (done) => {
|
|
807
|
+
const mockCreateRoleErrorResponse = {
|
|
808
|
+
error: {
|
|
809
|
+
status: false,
|
|
810
|
+
message: 'Role type is required.',
|
|
811
|
+
body: { errorCodes: ['3014'] },
|
|
812
|
+
},
|
|
813
|
+
status: 400,
|
|
814
|
+
statusText: 'OK',
|
|
815
|
+
};
|
|
816
|
+
const mockCreateRolePayload =
|
|
817
|
+
TenantsMocks.mockCreateRolePayloadMissingRoleType;
|
|
818
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
819
|
+
throwError(() => new HttpErrorResponse(mockCreateRoleErrorResponse))
|
|
820
|
+
);
|
|
821
|
+
service.createRole(mockCreateRolePayload).subscribe({
|
|
822
|
+
next: () => {
|
|
823
|
+
done();
|
|
824
|
+
},
|
|
825
|
+
error: (error: HttpErrorResponse) => {
|
|
826
|
+
done();
|
|
827
|
+
expect(error).toEqual(
|
|
828
|
+
new HttpErrorResponse(mockCreateRoleErrorResponse)
|
|
829
|
+
);
|
|
830
|
+
},
|
|
831
|
+
});
|
|
832
|
+
});
|
|
833
|
+
it('should handle error while creating a role is failed', (done) => {
|
|
834
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
835
|
+
throwError(() => new HttpErrorResponse(mockErrorResponse))
|
|
836
|
+
);
|
|
837
|
+
service.createRole(createRoleMockPayload).subscribe({
|
|
838
|
+
next: () => {
|
|
839
|
+
done();
|
|
840
|
+
},
|
|
841
|
+
error: (error: HttpErrorResponse) => {
|
|
842
|
+
done();
|
|
843
|
+
expect(error).toBeTruthy();
|
|
844
|
+
},
|
|
845
|
+
});
|
|
846
|
+
});
|
|
847
|
+
});
|
|
848
|
+
describe('#setNewlyCreatedRoleInfo', () => {
|
|
849
|
+
it('should set the create role info.', () => {
|
|
850
|
+
service.newlyCreatedRole = TenantsMocks?.createRoleMockPayload?.payload;
|
|
851
|
+
expect(service.getNewlyCreatedRoleInfo()).toEqual(
|
|
852
|
+
TenantsMocks?.createRoleMockPayload?.payload
|
|
853
|
+
);
|
|
854
|
+
});
|
|
855
|
+
});
|
|
856
|
+
describe('#deleteRole', () => {
|
|
857
|
+
it('should delete the role successfully', () => {
|
|
858
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
859
|
+
of(TenantsMocks.deleteRoleMockResponse)
|
|
860
|
+
);
|
|
861
|
+
service
|
|
862
|
+
.deleteRole(TenantsMocks.deleteRoleMockPayload)
|
|
863
|
+
.subscribe((response) => {
|
|
864
|
+
expect(response).toEqual(TenantsMocks.deleteRoleMockResponse);
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
it('should throw Role Id not found error while deleting the role', (done) => {
|
|
868
|
+
const mockDeleteRoleErrorResponse = {
|
|
869
|
+
error: {
|
|
870
|
+
status: false,
|
|
871
|
+
message: 'Role Id not found.',
|
|
872
|
+
body: { errorCodes: ['3010'] },
|
|
873
|
+
},
|
|
874
|
+
status: 400,
|
|
875
|
+
statusText: 'OK',
|
|
876
|
+
};
|
|
877
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
878
|
+
throwError(() => new HttpErrorResponse(mockDeleteRoleErrorResponse))
|
|
879
|
+
);
|
|
880
|
+
service.deleteRole(TenantsMocks.deleteRoleMockPayload).subscribe({
|
|
881
|
+
next: () => {
|
|
882
|
+
done();
|
|
883
|
+
},
|
|
884
|
+
error: (error: HttpErrorResponse) => {
|
|
885
|
+
done();
|
|
886
|
+
expect(error).toEqual(
|
|
887
|
+
new HttpErrorResponse(mockDeleteRoleErrorResponse)
|
|
888
|
+
);
|
|
889
|
+
},
|
|
890
|
+
});
|
|
891
|
+
});
|
|
892
|
+
it('should handle error while deleting a role is failed', (done) => {
|
|
893
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
894
|
+
throwError(() => new HttpErrorResponse(mockErrorResponse))
|
|
895
|
+
);
|
|
896
|
+
service.deleteRole(TenantsMocks.deleteRoleMockPayload).subscribe({
|
|
897
|
+
next: () => {
|
|
898
|
+
done();
|
|
899
|
+
},
|
|
900
|
+
error: (error: HttpErrorResponse) => {
|
|
901
|
+
done();
|
|
902
|
+
expect(error).toBeTruthy();
|
|
903
|
+
},
|
|
904
|
+
});
|
|
905
|
+
});
|
|
906
|
+
});
|
|
907
|
+
describe('#editRole', () => {
|
|
908
|
+
it('should update the modified role successfully', () => {
|
|
909
|
+
spyOn(httpService, 'putData').and.returnValue(of(editRoleMockResponse));
|
|
910
|
+
service.editRole(createRoleMockPayload).subscribe((response) => {
|
|
911
|
+
expect(response).toEqual(editRoleMockResponse);
|
|
912
|
+
});
|
|
913
|
+
});
|
|
914
|
+
it('should throw custom error for updating a role when role name is empty', (done) => {
|
|
915
|
+
const mockEditRoleErrorResponse = {
|
|
916
|
+
error: {
|
|
917
|
+
status: false,
|
|
918
|
+
message: 'Role Name is required.',
|
|
919
|
+
body: { errorCodes: ['3016'] },
|
|
920
|
+
},
|
|
921
|
+
status: 400,
|
|
922
|
+
statusText: 'OK',
|
|
923
|
+
};
|
|
924
|
+
const mockEditRolePayload =
|
|
925
|
+
TenantsMocks.mockEditRolePayloadMissingRoleName;
|
|
926
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
927
|
+
throwError(() => new HttpErrorResponse(mockEditRoleErrorResponse))
|
|
928
|
+
);
|
|
929
|
+
service.editRole(mockEditRolePayload).subscribe({
|
|
930
|
+
next: () => {
|
|
931
|
+
done();
|
|
932
|
+
},
|
|
933
|
+
error: (error: HttpErrorResponse) => {
|
|
934
|
+
done();
|
|
935
|
+
expect(error).toEqual(
|
|
936
|
+
new HttpErrorResponse(mockEditRoleErrorResponse)
|
|
937
|
+
);
|
|
938
|
+
},
|
|
939
|
+
});
|
|
940
|
+
});
|
|
941
|
+
it('should handle error while creating a role is failed', (done) => {
|
|
942
|
+
spyOn(httpService, 'putData').and.returnValue(
|
|
943
|
+
throwError(() => new HttpErrorResponse(mockErrorResponse))
|
|
944
|
+
);
|
|
945
|
+
service.editRole(createRoleMockPayload).subscribe({
|
|
946
|
+
next: () => {
|
|
947
|
+
done();
|
|
948
|
+
},
|
|
949
|
+
error: (error: HttpErrorResponse) => {
|
|
950
|
+
done();
|
|
951
|
+
expect(error).toBeTruthy();
|
|
952
|
+
},
|
|
953
|
+
});
|
|
954
|
+
});
|
|
955
|
+
});
|
|
956
|
+
describe('#setRolesInfo', () => {
|
|
957
|
+
it('should set the role info list.', () => {
|
|
958
|
+
service.setRolesInfo(TenantsMocks?.mockUserRoles?.body);
|
|
959
|
+
expect(service.getRolesInfo()).toEqual(TenantsMocks?.mockUserRoles?.body);
|
|
960
|
+
});
|
|
961
|
+
});
|
|
962
|
+
describe('#setSelectedRoleInformation', () => {
|
|
963
|
+
it('should set the selected role information.', () => {
|
|
964
|
+
service.setSelectedRoleInformation(TenantsMocks?.mockRoleInfo);
|
|
965
|
+
expect(service.getSelectedRoleInformation()).toEqual(
|
|
966
|
+
TenantsMocks?.mockRoleInfo
|
|
967
|
+
);
|
|
968
|
+
});
|
|
969
|
+
});
|
|
970
|
+
describe('#setRoleTypeOption', () => {
|
|
971
|
+
it('should set the selected role type option.', () => {
|
|
972
|
+
service.setRoleTypeOption(TenantsMocks?.mockRoleTypesFormattedResponse);
|
|
973
|
+
expect(service.getRoleTypeOption()).toEqual(
|
|
974
|
+
TenantsMocks?.mockRoleTypesFormattedResponse
|
|
975
|
+
);
|
|
976
|
+
});
|
|
977
|
+
});
|
|
978
|
+
describe('#getPermissions', () => {
|
|
979
|
+
it('should get the permissions configured for the tenant', () => {
|
|
980
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
981
|
+
of(TenantsMocks.permissionsSuccessResponse)
|
|
982
|
+
);
|
|
983
|
+
service.getPermissions('SAAPS').subscribe((response) => {
|
|
984
|
+
expect(response).toEqual(TenantsMocks.permissionsSuccessResponse);
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
it('should return error in retrieving permissions list', (done) => {
|
|
988
|
+
const mockPermissionsErrorResponse =
|
|
989
|
+
TenantsMocks.permissionsFailureResponse;
|
|
990
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
991
|
+
throwError(() => new HttpErrorResponse(mockPermissionsErrorResponse))
|
|
992
|
+
);
|
|
993
|
+
service.getPermissions('SAAPS').subscribe({
|
|
994
|
+
next: () => {
|
|
995
|
+
done();
|
|
996
|
+
},
|
|
997
|
+
error: (error: HttpErrorResponse) => {
|
|
998
|
+
done();
|
|
999
|
+
expect(error).toBeTruthy();
|
|
1000
|
+
},
|
|
1001
|
+
});
|
|
1002
|
+
});
|
|
1003
|
+
});
|
|
1004
|
+
describe('#getRolePermissionMapping', () => {
|
|
1005
|
+
it('should get the permissions based on the role selection.', () => {
|
|
1006
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
1007
|
+
of(TenantsMocks.getPermissionsByRoleIdSuccessResponse)
|
|
1008
|
+
);
|
|
1009
|
+
const payload: RolePermissionMappingRequestPayload = {
|
|
1010
|
+
payload: {
|
|
1011
|
+
appId: 'NESC',
|
|
1012
|
+
permissionId: null,
|
|
1013
|
+
roleId: 'RT_NESC_6537b7bc-2006-4395-9d77-b2e31d1db522',
|
|
1014
|
+
},
|
|
1015
|
+
};
|
|
1016
|
+
service.getRolePermissionMapping(payload).subscribe((response) => {
|
|
1017
|
+
expect(response).toEqual(
|
|
1018
|
+
TenantsMocks.getPermissionsByRoleIdSuccessResponse
|
|
1019
|
+
);
|
|
1020
|
+
});
|
|
1021
|
+
});
|
|
1022
|
+
it('should return error while retrieving permissions list based on role selection.', (done) => {
|
|
1023
|
+
const errorResponse = { status: 500, message: 'Internal Server Error' };
|
|
1024
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
1025
|
+
throwError(() => new HttpErrorResponse(errorResponse))
|
|
1026
|
+
);
|
|
1027
|
+
const payload: RolePermissionMappingRequestPayload = {
|
|
1028
|
+
payload: {
|
|
1029
|
+
appId: 'NESC',
|
|
1030
|
+
permissionId: null,
|
|
1031
|
+
roleId: 'RT_NESC_6537b7bc-2006-4395-9d77-b2e31d1db522',
|
|
1032
|
+
},
|
|
1033
|
+
};
|
|
1034
|
+
service.getRolePermissionMapping(payload).subscribe({
|
|
1035
|
+
next: () => {
|
|
1036
|
+
done();
|
|
1037
|
+
},
|
|
1038
|
+
error: (error: HttpErrorResponse) => {
|
|
1039
|
+
done();
|
|
1040
|
+
expect(error).toBeTruthy();
|
|
1041
|
+
},
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
it('should get the roles based on the permission selection.', () => {
|
|
1045
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
1046
|
+
of(TenantsMocks.getRolesByPermissionIdSuccessResponse)
|
|
1047
|
+
);
|
|
1048
|
+
const payload: RolePermissionMappingRequestPayload = {
|
|
1049
|
+
payload: {
|
|
1050
|
+
appId: 'NESC',
|
|
1051
|
+
permissionId: 'PERM_NESC_68041ee9-3035-4136-9091-db42700a6204',
|
|
1052
|
+
roleId: null,
|
|
1053
|
+
},
|
|
1054
|
+
};
|
|
1055
|
+
service.getRolePermissionMapping(payload).subscribe((response) => {
|
|
1056
|
+
expect(response).toEqual(
|
|
1057
|
+
TenantsMocks.getRolesByPermissionIdSuccessResponse
|
|
1058
|
+
);
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1061
|
+
it('should return error while retrieving roles based on permission selection.', (done) => {
|
|
1062
|
+
const errorResponse = { status: 500, message: 'Internal Server Error' };
|
|
1063
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
1064
|
+
throwError(() => new HttpErrorResponse(errorResponse))
|
|
1065
|
+
);
|
|
1066
|
+
const payload: RolePermissionMappingRequestPayload = {
|
|
1067
|
+
payload: {
|
|
1068
|
+
appId: 'NESC',
|
|
1069
|
+
permissionId: 'PERM_NESC_68041ee9-3035-4136-9091-db42700a6204',
|
|
1070
|
+
roleId: null,
|
|
1071
|
+
},
|
|
1072
|
+
};
|
|
1073
|
+
service.getRolePermissionMapping(payload).subscribe({
|
|
1074
|
+
next: () => {
|
|
1075
|
+
done();
|
|
1076
|
+
},
|
|
1077
|
+
error: (error: HttpErrorResponse) => {
|
|
1078
|
+
done();
|
|
1079
|
+
expect(error).toBeTruthy();
|
|
1080
|
+
},
|
|
1081
|
+
});
|
|
1082
|
+
});
|
|
1083
|
+
it('should get the permissions based on the role and permission selection.', () => {
|
|
1084
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
1085
|
+
of(TenantsMocks.getPermissionsByRoleIdAndPermissionIdSuccessResponse)
|
|
1086
|
+
);
|
|
1087
|
+
const payload: RolePermissionMappingRequestPayload = {
|
|
1088
|
+
payload: {
|
|
1089
|
+
appId: 'NESC',
|
|
1090
|
+
permissionId: 'PERM_NESC_68041ee9-3035-4136-9091-db42700a6204',
|
|
1091
|
+
roleId: 'RT_NESC_6537b7bc-2006-4395-9d77-b2e31d1db522',
|
|
1092
|
+
},
|
|
1093
|
+
};
|
|
1094
|
+
service.getRolePermissionMapping(payload).subscribe((response) => {
|
|
1095
|
+
expect(response).toEqual(
|
|
1096
|
+
TenantsMocks.getPermissionsByRoleIdAndPermissionIdSuccessResponse
|
|
1097
|
+
);
|
|
1098
|
+
});
|
|
1099
|
+
});
|
|
1100
|
+
it('should return error while retrieving permissions list based on role selection.', (done) => {
|
|
1101
|
+
const errorResponse = { status: 500, message: 'Internal Server Error' };
|
|
1102
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
1103
|
+
throwError(() => new HttpErrorResponse(errorResponse))
|
|
1104
|
+
);
|
|
1105
|
+
const payload: RolePermissionMappingRequestPayload = {
|
|
1106
|
+
payload: {
|
|
1107
|
+
appId: 'NESC',
|
|
1108
|
+
permissionId: null,
|
|
1109
|
+
roleId: 'RT_NESC_6537b7bc-2006-4395-9d77-b2e31d1db522',
|
|
1110
|
+
},
|
|
1111
|
+
};
|
|
1112
|
+
service.getRolePermissionMapping(payload).subscribe({
|
|
1113
|
+
next: () => {
|
|
1114
|
+
done();
|
|
1115
|
+
},
|
|
1116
|
+
error: (error: HttpErrorResponse) => {
|
|
1117
|
+
done();
|
|
1118
|
+
expect(error).toBeTruthy();
|
|
1119
|
+
},
|
|
1120
|
+
});
|
|
1121
|
+
});
|
|
1122
|
+
});
|
|
1123
|
+
describe('#saveRolePermissionMapping', () => {
|
|
1124
|
+
it('should save the role and permissions mapping changes.', () => {
|
|
1125
|
+
const payload: RolesAndPermissionsRequestPayload = {
|
|
1126
|
+
payload: [
|
|
1127
|
+
{
|
|
1128
|
+
appId: 'NESC',
|
|
1129
|
+
permissionId: 'PERM_NESC_c05ff592-7178-4614-b730-7a7a8828824e',
|
|
1130
|
+
roleId: 'RT_NESC_44e33b17-053c-4e0f-9d01-71b5604cbc7f',
|
|
1131
|
+
status: true,
|
|
1132
|
+
},
|
|
1133
|
+
],
|
|
1134
|
+
};
|
|
1135
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
1136
|
+
of(TenantsMocks.saveRolePermissionMappingSuccessResponse)
|
|
1137
|
+
);
|
|
1138
|
+
service.saveRolePermissionMapping(payload).subscribe((response) => {
|
|
1139
|
+
expect(response).toEqual(
|
|
1140
|
+
TenantsMocks.saveRolePermissionMappingSuccessResponse
|
|
1141
|
+
);
|
|
1142
|
+
});
|
|
1143
|
+
});
|
|
1144
|
+
it('should return error while saving roles and permissions.', (done) => {
|
|
1145
|
+
const errorResponse = { status: 500, message: 'Internal Server Error' };
|
|
1146
|
+
const payload: RolesAndPermissionsRequestPayload = {
|
|
1147
|
+
payload: [
|
|
1148
|
+
{
|
|
1149
|
+
appId: 'NESC',
|
|
1150
|
+
permissionId: 'PERM_NESC_c05ff592-7178-4614-b730-7a7a8828824e',
|
|
1151
|
+
roleId: 'RT_NESC_44e33b17-053c-4e0f-9d01-71b5604cbc7f',
|
|
1152
|
+
status: true,
|
|
1153
|
+
},
|
|
1154
|
+
],
|
|
1155
|
+
};
|
|
1156
|
+
spyOn(httpService, 'postData').and.returnValue(
|
|
1157
|
+
throwError(() => new HttpErrorResponse(errorResponse))
|
|
1158
|
+
);
|
|
1159
|
+
service.saveRolePermissionMapping(payload).subscribe({
|
|
1160
|
+
next: () => {
|
|
1161
|
+
done();
|
|
1162
|
+
},
|
|
1163
|
+
error: (error: HttpErrorResponse) => {
|
|
1164
|
+
done();
|
|
1165
|
+
expect(error).toBeTruthy();
|
|
1166
|
+
},
|
|
1167
|
+
});
|
|
1168
|
+
});
|
|
1169
|
+
});
|
|
1170
|
+
describe('#getGroupTypes', () => {
|
|
1171
|
+
it('should return group types success response', () => {
|
|
1172
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
1173
|
+
of(TenantsMocks.mockGroupTypeResponse)
|
|
1174
|
+
);
|
|
1175
|
+
service.getGroupTypes('testAppId').subscribe((response) => {
|
|
1176
|
+
expect(response).toEqual(TenantsMocks?.mockGroupTypeResponse);
|
|
1177
|
+
});
|
|
1178
|
+
});
|
|
1179
|
+
it('should return custom error in retrieving group types', (done) => {
|
|
1180
|
+
const mockGetGroupTypesErrorResponse = {
|
|
1181
|
+
error: {
|
|
1182
|
+
status: false,
|
|
1183
|
+
message: 'Group Type(s) not found.',
|
|
1184
|
+
body: { errorCodes: ['1010'] },
|
|
1185
|
+
},
|
|
1186
|
+
status: 404,
|
|
1187
|
+
statusText: 'OK',
|
|
1188
|
+
};
|
|
1189
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
1190
|
+
throwError(() => new HttpErrorResponse(mockGetGroupTypesErrorResponse))
|
|
1191
|
+
);
|
|
1192
|
+
service.getGroupTypes('').subscribe({
|
|
1193
|
+
next: () => {
|
|
1194
|
+
done();
|
|
1195
|
+
},
|
|
1196
|
+
error: (error: HttpErrorResponse) => {
|
|
1197
|
+
done();
|
|
1198
|
+
expect(error).toBeTruthy();
|
|
1199
|
+
},
|
|
1200
|
+
});
|
|
1201
|
+
});
|
|
1202
|
+
it('should return error in retrieving group types', (done) => {
|
|
1203
|
+
spyOn(httpService, 'getData').and.returnValue(
|
|
1204
|
+
throwError(
|
|
1205
|
+
() =>
|
|
1206
|
+
new HttpErrorResponse({
|
|
1207
|
+
error: 'Test error',
|
|
1208
|
+
status: 500,
|
|
1209
|
+
statusText: 'Internal server error',
|
|
1210
|
+
})
|
|
1211
|
+
)
|
|
1212
|
+
);
|
|
1213
|
+
service.getGroupTypes('').subscribe({
|
|
1214
|
+
next: () => {
|
|
1215
|
+
done();
|
|
1216
|
+
},
|
|
1217
|
+
error: (error: HttpErrorResponse) => {
|
|
1218
|
+
done();
|
|
1219
|
+
expect(error).toBeTruthy();
|
|
1220
|
+
},
|
|
1221
|
+
});
|
|
1222
|
+
});
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
describe('#setGroupTypeDetails', () => {
|
|
1226
|
+
it('should call setGroupTypeDetails method and set setGroupTypeDetails', () => {
|
|
1227
|
+
const setGroupTypeDetailsSpy = spyOn(
|
|
1228
|
+
service,
|
|
1229
|
+
'setGroupTypeDetails'
|
|
1230
|
+
).and.callThrough();
|
|
1231
|
+
service.setGroupTypeDetails(TenantsMocks.mockGroupTypeResponse);
|
|
1232
|
+
expect(setGroupTypeDetailsSpy).toHaveBeenCalledWith(
|
|
1233
|
+
TenantsMocks.mockGroupTypeResponse
|
|
1234
|
+
);
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1237
|
+
describe('#getGroupTypeDetails', () => {
|
|
1238
|
+
it('should return group type details', () => {
|
|
1239
|
+
service.setGroupTypeDetails(TenantsMocks.mockGroupTypeResponse);
|
|
1240
|
+
expect(service.getGroupTypeDetails()).toEqual(
|
|
1241
|
+
TenantsMocks.mockGroupTypeResponse
|
|
1242
|
+
);
|
|
1243
|
+
});
|
|
1244
|
+
});
|
|
1245
|
+
});
|