-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfiguration.service.spec.ts
More file actions
68 lines (56 loc) · 1.84 KB
/
Copy pathconfiguration.service.spec.ts
File metadata and controls
68 lines (56 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { TestBed } from '@angular/core/testing';
import { ConfigurationService } from './configuration.service';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { ConfigurationModel } from './configuration.model';
import { configuration, helpUrl } from '../../shared/test/test-data';
import { HelpUrlModel } from './HelpUrl.model';
describe('configurationService', () => {
let httpMock: HttpTestingController;
let service: ConfigurationService;
const API_URL = '/api/v1/configuration/authorization';
beforeEach(() => {
TestBed.configureTestingModule({
providers: [provideHttpClient(),
provideHttpClientTesting()]
})
.compileComponents();
service = TestBed.inject(ConfigurationService);
httpMock = TestBed.inject(HttpTestingController);
});
afterEach(() => {
httpMock.verify();
});
it('should be created', () => {
expect(service)
.toBeTruthy();
});
describe('Configuration endpoint', () => {
it('should fetch configuration', () => {
const mockConfig: ConfigurationModel = configuration;
service.getConfiguration()
.subscribe((config) => {
expect(config)
.toEqual(mockConfig);
});
const req = httpMock.expectOne(API_URL);
expect(req.request.method)
.toBe('GET');
req.flush(mockConfig);
});
});
describe('Supportpageurl endpoint', () => {
it('should fetch url', () => {
const mockUrl: HelpUrlModel = helpUrl;
service.getConfiguration()
.subscribe((response) => {
expect(response)
.toEqual(mockUrl);
});
const req = httpMock.expectOne(API_URL);
expect(req.request.method)
.toBe('GET');
req.flush(mockUrl);
});
});
});