Skip to content

Commit 5ac2125

Browse files
committed
refactor: reorganize imports in application-info.client.ts; add unit tests for ApplicationInfoClient
1 parent 6c59d06 commit 5ac2125

2 files changed

Lines changed: 65 additions & 3 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import {
2+
provideHttpClient
3+
} from '@angular/common/http';
4+
import {
5+
HttpTestingController,
6+
provideHttpClientTesting
7+
} from '@angular/common/http/testing';
8+
import {
9+
TestBed
10+
} from '@angular/core/testing';
11+
12+
import {
13+
ApplicationInfoClient
14+
} from './application-info.client';
15+
16+
describe('ApplicationInfoClient', () => {
17+
let client: ApplicationInfoClient;
18+
let httpTestingController: HttpTestingController;
19+
20+
beforeEach(() => {
21+
TestBed.configureTestingModule({
22+
providers: [
23+
ApplicationInfoClient,
24+
provideHttpClient(),
25+
provideHttpClientTesting()
26+
]
27+
});
28+
29+
client = TestBed.inject(ApplicationInfoClient);
30+
31+
httpTestingController =
32+
TestBed.inject(HttpTestingController);
33+
});
34+
35+
afterEach(() => {
36+
httpTestingController.verify();
37+
});
38+
39+
it('should retrieve the application version', () => {
40+
client.getVersion().subscribe(version => {
41+
expect(version).toBe('0.4.12');
42+
});
43+
44+
const request =
45+
httpTestingController.expectOne('/actuator/info');
46+
47+
expect(request.request.method).toBe('GET');
48+
49+
request.flush({
50+
build: {
51+
version: '0.4.12'
52+
}
53+
});
54+
});
55+
});

ui/src/infrastructure/client/application-info.client.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import { HttpClient } from '@angular/common/http';
2-
import { Injectable } from '@angular/core';
3-
import { map, Observable } from 'rxjs';
1+
import {
2+
HttpClient
3+
} from '@angular/common/http';
4+
import {
5+
Injectable
6+
} from '@angular/core';
7+
import {
8+
map,
9+
Observable
10+
} from 'rxjs';
411

512
interface ApplicationInfoResponse {
613
build: {

0 commit comments

Comments
 (0)