Skip to content

Commit 955b9bd

Browse files
committed
Tests Cases Review
1 parent 1d2d861 commit 955b9bd

File tree

1 file changed

+28
-41
lines changed

1 file changed

+28
-41
lines changed

client/src/app/api/api/api.service.spec.ts

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
* limitations under the License.
1717
*/
1818

19-
import { TestBed, async, inject } from '@angular/core/testing';
19+
import { TestBed, async,fakeAsync, inject } from '@angular/core/testing';
2020
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2121
import { ApiService } from './api.service';
22-
import {HttpClientModule, HttpRequest, HttpParams, HttpClient} from '@angular/common/http';
23-
22+
import { HttpClientModule } from '@angular/common/http';
2423

2524
describe('ApiService', () => {
2625

27-
2826
let service, http;
2927

3028
beforeEach(() => {
@@ -33,7 +31,7 @@ describe('ApiService', () => {
3331
providers: [ApiService],
3432
});
3533

36-
service = TestBed.get(ApiService);
34+
service = TestBed.get(ApiService);
3735
http = TestBed.get(HttpTestingController);
3836
});
3937

@@ -42,49 +40,38 @@ describe('ApiService', () => {
4240
backend.verify();
4341
}));
4442

45-
it('should be created', inject([ApiService], (apiService: ApiService) => {
43+
it('should be created an instance', inject([ApiService], (apiService: ApiService) => {
4644
expect(apiService).toBeTruthy();
4745
}));
4846

49-
it(`should post the Instance type and instance name in backend to deploy an instance`,
47+
it(`should create an instance`,
48+
async(inject([ApiService], (apiService: ApiService) => {
49+
expect(apiService.postInstance('', '')).not.toBeNull();
50+
})));
51+
52+
it(`should start an instance`,
5053
async(inject([ApiService], (apiService: ApiService) => {
51-
spyOn(apiService, 'commonConf');
52-
apiService.postAction('endpoint', 'idInstance');
53-
expect(apiService.commonConf).toHaveBeenCalled();
54-
})));
54+
expect(apiService.startInstance('', '')).not.toBeNull();
55+
})));
5556

56-
it(`should post an instance calling postAction`, async(inject([ApiService], (apiService: ApiService) => {
57-
spyOn(apiService, 'post');
58-
apiService.postInstance('id', 'name');
59-
expect(apiService.post).toHaveBeenCalled();
60-
})));
61-
it(`should start an instance calling postAction`, async(inject([ApiService], (apiService: ApiService) => {
62-
spyOn(apiService, 'postAction');
63-
apiService.startInstance('id');
64-
expect(apiService.postAction).toHaveBeenCalled();
65-
})));
57+
it(`should stop an instance`,
58+
async(inject([ApiService], (apiService: ApiService) => {
59+
expect(apiService.stopInstance('', '')).not.toBeNull();
60+
})));
6661

67-
it(`should stop an instance calling postAction`, async(inject([ApiService], (apiService: ApiService) => {
68-
spyOn(apiService, 'postAction');
69-
apiService.stopInstance('id');
70-
expect(apiService.postAction).toHaveBeenCalled();
71-
})));
62+
it(`should pause an instance`,
63+
async(inject([ApiService], (apiService: ApiService) => {
64+
expect(apiService.pauseInstance('')).not.toBeNull();
65+
})));
7266

73-
it(`should pause an instance calling postAction`, async(inject([ApiService], (apiService: ApiService) => {
74-
spyOn(apiService, 'postAction');
75-
apiService.pauseInstance('id');
76-
expect(apiService.postAction).toHaveBeenCalled();
77-
})));
67+
it(`should resume an instance`,
68+
async(inject([ApiService], (apiService: ApiService) => {
69+
expect(apiService.resumeInstance('')).not.toBeNull();
70+
})));
7871

79-
it(`should resume an instance calling postAction`, async(inject([ApiService], (apiService: ApiService) => {
80-
spyOn(apiService, 'postAction');
81-
apiService.resumeInstance('id');
82-
expect(apiService.postAction).toHaveBeenCalled();
83-
})));
72+
it(`should delete an instance`,
73+
async(inject([ApiService], (apiService: ApiService) => {
74+
expect(apiService.deleteInstance('')).not.toBeNull();
75+
})));
8476

85-
it(`should delete an instance calling postAction`, async(inject([ApiService], (apiService: ApiService) => {
86-
spyOn(apiService, 'postAction');
87-
apiService.deleteInstance('id');
88-
expect(apiService.postAction).toHaveBeenCalled();
89-
})));
9077
});

0 commit comments

Comments
 (0)