Skip to content

Commit 2409622

Browse files
committed
improved status card test by adding dummy data to check
1 parent 07d2a2c commit 2409622

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

client/src/app/dashboard/status-card/status-card.component.spec.ts

+27-4
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,35 @@
1717
*/
1818

1919
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
20-
import { HttpClientTestingModule } from '@angular/common/http/testing';
21-
import { HttpClientModule } from '@angular/common/http';
2220
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';
2324

2425

2526
describe('StatusCardComponent', () => {
2627
let component: StatusCardComponent;
2728
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';
2933
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+
};
3045
TestBed.configureTestingModule({
3146
declarations: [ StatusCardComponent ],
32-
imports: [HttpClientTestingModule, HttpClientModule]
47+
imports: [],
48+
providers: [{provide: ApiService, useValue: apiServiceStub}]
3349
})
3450
.compileComponents();
3551
}));
@@ -43,4 +59,11 @@ describe('StatusCardComponent', () => {
4359
it('should create', () => {
4460
expect(component).toBeTruthy();
4561
});
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+
});
4669
});

0 commit comments

Comments
 (0)