17
17
*/
18
18
19
19
import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
20
- import { HttpClientTestingModule } from '@angular/common/http/testing' ;
21
- import { HttpClientModule } from '@angular/common/http' ;
22
20
import { StatusCardComponent } from './status-card.component' ;
21
+ import { ApiService } from 'src/app/api/api/api.service' ;
22
+ import { Observable } from 'rxjs' ;
23
+ import { SysInfo } from 'src/app/model/models/sysInfo' ;
23
24
24
25
25
26
describe ( 'StatusCardComponent' , ( ) => {
26
27
let component : StatusCardComponent ;
27
28
let fixture : ComponentFixture < StatusCardComponent > ;
28
-
29
+ const JAVA_VERSION = '1.0' ;
30
+ const HOST_NAME = 'My Host Name' ;
31
+ const PLATFORM_NAME = 'My Platform Name' ;
32
+ const SCALA_VERSION = '2.0' ;
29
33
beforeEach ( async ( ( ) => {
34
+ let apiServiceStub : Partial < ApiService > ;
35
+ apiServiceStub = {
36
+ getSysInfo : ( ) => new Observable < SysInfo > ( ( observer ) => {
37
+ observer . next ( {
38
+ javaVersion : JAVA_VERSION ,
39
+ hostName : HOST_NAME ,
40
+ platformName : PLATFORM_NAME ,
41
+ scalaVersion : SCALA_VERSION
42
+ } ) ;
43
+ } )
44
+ } ;
30
45
TestBed . configureTestingModule ( {
31
46
declarations : [ StatusCardComponent ] ,
32
- imports : [ HttpClientTestingModule , HttpClientModule ]
47
+ imports : [ ] ,
48
+ providers : [ { provide : ApiService , useValue : apiServiceStub } ]
33
49
} )
34
50
. compileComponents ( ) ;
35
51
} ) ) ;
@@ -43,4 +59,11 @@ describe('StatusCardComponent', () => {
43
59
it ( 'should create' , ( ) => {
44
60
expect ( component ) . toBeTruthy ( ) ;
45
61
} ) ;
62
+
63
+ it ( 'should have the dummy data stored' , ( ) => {
64
+ expect ( component . sysInfo . hostName ) . toBe ( HOST_NAME ) ;
65
+ expect ( component . sysInfo . javaVersion ) . toBe ( JAVA_VERSION ) ;
66
+ expect ( component . sysInfo . platformName ) . toBe ( PLATFORM_NAME ) ;
67
+ expect ( component . sysInfo . scalaVersion ) . toBe ( SCALA_VERSION ) ;
68
+ } ) ;
46
69
} ) ;
0 commit comments