16
16
* limitations under the License.
17
17
*/
18
18
19
- import { TestBed , async , inject } from '@angular/core/testing' ;
19
+ import { TestBed , async , fakeAsync , inject } from '@angular/core/testing' ;
20
20
import { HttpClientTestingModule , HttpTestingController } from '@angular/common/http/testing' ;
21
21
import { ApiService } from './api.service' ;
22
- import { HttpClientModule , HttpRequest , HttpParams , HttpClient } from '@angular/common/http' ;
23
-
22
+ import { HttpClientModule } from '@angular/common/http' ;
24
23
25
24
describe ( 'ApiService' , ( ) => {
26
25
27
-
28
26
let service , http ;
29
27
30
28
beforeEach ( ( ) => {
@@ -33,7 +31,7 @@ describe('ApiService', () => {
33
31
providers : [ ApiService ] ,
34
32
} ) ;
35
33
36
- service = TestBed . get ( ApiService ) ;
34
+ service = TestBed . get ( ApiService ) ;
37
35
http = TestBed . get ( HttpTestingController ) ;
38
36
} ) ;
39
37
@@ -42,49 +40,38 @@ describe('ApiService', () => {
42
40
backend . verify ( ) ;
43
41
} ) ) ;
44
42
45
- it ( 'should be created' , inject ( [ ApiService ] , ( apiService : ApiService ) => {
43
+ it ( 'should be created an instance ' , inject ( [ ApiService ] , ( apiService : ApiService ) => {
46
44
expect ( apiService ) . toBeTruthy ( ) ;
47
45
} ) ) ;
48
46
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` ,
50
53
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
+ } ) ) ) ;
55
56
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
+ } ) ) ) ;
66
61
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
+ } ) ) ) ;
72
66
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
+ } ) ) ) ;
78
71
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
+ } ) ) ) ;
84
76
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
- } ) ) ) ;
90
77
} ) ;
0 commit comments