blob: 78c1b5ab990f4191fdec5ac5f68c8072b0d80e18 [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001import {getTestBed, TestBed} from '@angular/core/testing';
2import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
3import {ServiceInfoService} from './serviceInfo.service';
4import {ServiceInfoModel} from './serviceInfo.model';
5import {Constants} from "../../utils/constants";
6
7describe('Service Info Service', () => {
8 let injector;
9 let service: ServiceInfoService;
10 let httpMock: HttpTestingController;
11
12 beforeEach(() => {
13 TestBed.configureTestingModule({
14 imports: [HttpClientTestingModule],
15 providers: [ServiceInfoService]
16 });
17
18 injector = getTestBed();
19 service = injector.get(ServiceInfoService);
20 httpMock = injector.get(HttpTestingController);
21 });
22
23 describe('#getServicesJobInfo', () => {
24 it('should return an Observable<ServiceInfoModel[]>', () => {
25 const dummyServiceInfo: ServiceInfoModel[] = generateServiceInfoData();
26
27 service.getServicesJobInfo(true).subscribe((serviceInfo:Array<ServiceInfoModel>) => {
28 expect(serviceInfo).toEqual(dummyServiceInfo);
29 });
30 });
31
32
33 });
34
35 describe('#deleteJob', () =>{
36 it('delete job', () => {
37 const jobId : string = "1111";
38
39 service.deleteJob(jobId).subscribe();
40
41 const req = httpMock.expectOne(Constants.Path.SERVICES_JOB_INFO_PATH + '/job/' + jobId);
42 expect(req.request.method).toEqual('DELETE');
43
44 });
45 });
46
47 describe('#hideJob', () =>{
48 it('when call hide job, there is http POST with right url', () => {
49 const jobId : string = "3";
50
51 service.hideJob(jobId).subscribe();
52
53 const req = httpMock.expectOne(Constants.Path.SERVICES_JOB_INFO_PATH + '/hide/' + jobId);
54 expect(req.request.method).toEqual('POST');
55 });
56 });
57
58 describe('#getJobAuditStatus', ()=> {
59 it('should return Observable<Object[]>', ()=>{
60 const jobId : string = '111';
61
62 service.getJobAuditStatus(jobId).subscribe();
63 const req = httpMock.expectOne(Constants.Path.SERVICES_JOB_INFO_PATH + Constants.Path.SERVICES_JOB_AUDIT_PATH + '/' + jobId + '?source=VID');
64 const req2 = httpMock.expectOne(Constants.Path.SERVICES_JOB_INFO_PATH + Constants.Path.SERVICES_JOB_AUDIT_PATH + '/' + jobId + '?source=MSO');
65
66 expect(req.request.method).toEqual('GET');
67 expect(req2.request.method).toEqual('GET');
68 });
69 });
70
71 function generateServiceInfoData(){
72 return <ServiceInfoModel[]>JSON.parse(JSON.stringify(
73 [{
74 "created": 1519956533000,
75 "modified": 1521727738000,
76 "createdId": null,
77 "modifiedId": null,
78 "rowNum": null,
79 "auditUserId": null,
80 "auditTrail": null,
81 "jobId": "6748648484",
82 "userId": "2222",
83 "jobStatus": "FAILED",
84 "pause": false,
85 "owningEntityId": "1234",
86 "owningEntityName": null,
87 "project": null,
88 "aicZoneId": null,
89 "aicZoneName": null,
90 "tenantId": null,
91 "tenantName": null,
92 "regionId": null,
93 "regionName": null,
94 "serviceType": null,
95 "subscriberName": null,
96 "serviceInstanceId": "1",
97 "serviceInstanceName": null,
98 "serviceModelId": null,
99 "serviceModelName": null,
100 "serviceModelVersion": null,
101 "createdBulkDate": 1519956533000,
102 "statusModifiedDate": 1520042933000,
103 "hidden": false
104 },
105 {
106 "created": 1519956533000,
107 "modified": 1521727738000,
108 "createdId": null,
109 "modifiedId": null,
110 "rowNum": null,
111 "auditUserId": null,
112 "auditTrail": null,
113 "jobId": "6748648484",
114 "userId": "2222",
115 "jobStatus": "FAILED",
116 "pause": false,
117 "owningEntityId": "1234",
118 "owningEntityName": null,
119 "project": null,
120 "aicZoneId": null,
121 "aicZoneName": null,
122 "tenantId": null,
123 "tenantName": null,
124 "regionId": null,
125 "regionName": null,
126 "serviceType": null,
127 "subscriberName": null,
128 "serviceInstanceId": "1",
129 "serviceInstanceName": null,
130 "serviceModelId": null,
131 "serviceModelName": null,
132 "serviceModelVersion": null,
133 "createdBulkDate": 1519956533000,
134 "statusModifiedDate": 1520042933000,
135 "hidden": false
136 },
137 {
138 "created": 1519956533000,
139 "modified": 1521727738000,
140 "createdId": null,
141 "modifiedId": null,
142 "rowNum": null,
143 "auditUserId": null,
144 "auditTrail": null,
145 "jobId": "6748648484",
146 "userId": "2222",
147 "jobStatus": "FAILED",
148 "pause": false,
149 "owningEntityId": "1234",
150 "owningEntityName": null,
151 "project": null,
152 "aicZoneId": null,
153 "aicZoneName": null,
154 "tenantId": null,
155 "tenantName": null,
156 "regionId": null,
157 "regionName": null,
158 "serviceType": null,
159 "subscriberName": null,
160 "serviceInstanceId": "2",
161 "serviceInstanceName": null,
162 "serviceModelId": null,
163 "serviceModelName": null,
164 "serviceModelVersion": null,
165 "createdBulkDate": 1519956533000,
166 "statusModifiedDate": 1520042933000,
167 "hidden": false
168 },
169 {
170 "created": 1519956533000,
171 "modified": 1521727738000,
172 "createdId": null,
173 "modifiedId": null,
174 "rowNum": null,
175 "auditUserId": null,
176 "auditTrail": null,
177 "jobId": "6748648484",
178 "userId": "2222",
179 "jobStatus": "FAILED",
180 "pause": false,
181 "owningEntityId": "1234",
182 "owningEntityName": null,
183 "project": null,
184 "aicZoneId": null,
185 "aicZoneName": null,
186 "tenantId": null,
187 "tenantName": null,
188 "regionId": null,
189 "regionName": null,
190 "serviceType": null,
191 "subscriberName": null,
192 "serviceInstanceId": "2",
193 "serviceInstanceName": null,
194 "serviceModelId": null,
195 "serviceModelName": null,
196 "serviceModelVersion": null,
197 "createdBulkDate": 1519956533000,
198 "statusModifiedDate": 1520042933000,
199 "hidden": false
200 },
201 {
202 "created": 1519956533000,
203 "modified": 1521727738000,
204 "createdId": null,
205 "modifiedId": null,
206 "rowNum": null,
207 "auditUserId": null,
208 "auditTrail": null,
209 "jobId": "6748648484",
210 "userId": "2222",
211 "jobStatus": "FAILED",
212 "pause": false,
213 "owningEntityId": "1234",
214 "owningEntityName": null,
215 "project": null,
216 "aicZoneId": null,
217 "aicZoneName": null,
218 "tenantId": null,
219 "tenantName": null,
220 "regionId": null,
221 "regionName": null,
222 "serviceType": null,
223 "subscriberName": null,
224 "serviceInstanceId": "3",
225 "serviceInstanceName": null,
226 "serviceModelId": null,
227 "serviceModelName": null,
228 "serviceModelVersion": null,
229 "createdBulkDate": 1519956533000,
230 "statusModifiedDate": 1520042933000,
231 "hidden": false
232 }]
233 ));
234 }
235});