blob: 80b113bde49654f438b5873d1ffb7492bfc6cbe5 (
plain)
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
|
import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing";
import {InstantiationTemplatesService} from "./instantiationTemplates.service";
import {mock} from "ts-mockito";
import {NgRedux} from "@angular-redux/store";
import {getTestBed, TestBed} from "@angular/core/testing";
import {ServiceInstance} from "../../models/serviceInstance";
import {Constants} from "../../utils/constants";
class MockAppStore<T> {
dispatch() {}
getState() {}
}
describe("TemplateService", ()=>{
let injector;
let httpMock: HttpTestingController;
let templateService: InstantiationTemplatesService;
beforeAll( done => (async () => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [
InstantiationTemplatesService,
{provide: NgRedux, useClass: MockAppStore},
]
});
await TestBed.compileComponents();
injector = getTestBed();
httpMock = injector.get(HttpTestingController);
templateService = injector.get(InstantiationTemplatesService);
})().then(done).catch(done.fail));
describe ('#retrieveInstantiationTemplateTopology tests', () => {
test('when called -> retrieve template from backend', done => {
const mockedTemplate = mock(ServiceInstance);
const jobId: string = "some-random-job-id";
templateService.retrieveInstantiationTemplateTopology(jobId)
.subscribe((result: ServiceInstance) => {
expect(Object.is(result, mockedTemplate)).toBe(true);
done();
});
httpMock
.expectOne(`${Constants.Path.INSTANTIATION_TEMPLATE_TOPOLOGY}/${jobId}`)
.flush(mockedTemplate);
})
})
});
|