Newer
Older
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import {TilesService} from './tiles.service';
import {Tile, TileDefinition} from "../model/tile";
import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing";
import {TestBed} from "@angular/core/testing";
import {ConfigurationService} from "../env/configuration.service";
import {RouterTestingModule} from "@angular/router/testing";
export class FakeConfigurationService {
get config() {
return {
dryrun: "false",
rootDataDirectory: "/lustre/aoc/cluster/pipeline/vlass_test/spool",
url: "http://localhost:4200/VlassMngr",
weblogbaseurl: "http://webtest.aoc.nrao.edu/",
projectcode: "VLASS1.1",
wsurl: "ws://localhost:8081/VlassMngr/changes",
currentepoch: "1"
};
}
}
describe('TilesService', () => {
let httpMock: HttpTestingController;
let tilesService: TilesService;
let fakeConfigService: FakeConfigurationService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, RouterTestingModule.withRoutes([])],
providers: [TilesService, {provide: ConfigurationService, useClass: FakeConfigurationService}]
});
tilesService = TestBed.get(TilesService);
httpMock = TestBed.get(HttpTestingController);
fakeConfigService = TestBed.get(ConfigurationService);
});
it('should get tiles for epoch', () => {
let expectedResults = [{
area: 23.64,
custom1: "VLASS1.1",
custom2: "2018-02-07",
custom3: "100% imaged",
custom4: null,
custom5: null,
decMax: -36,
decMin: -40,
epoch: 1,
factor: 1.73,
firstEpochHalf: true,
id: 1,
name: "Tile1",
raMax: 7.5,
raMin: 0,
tier: 1
} as Tile, {
area: 23.64,
custom1: "VLASS1.1",
custom2: "2018-02-03",
custom3: "100% imaged",
custom4: null,
custom5: null,
decMax: -36,
decMin: -40,
epoch: 1,
factor: 1.73,
firstEpochHalf: true,
id: 2,
name: "Tile2",
raMax: 15,
raMin: 7.5,
tier: 1
} as Tile
];
tilesService.getTilesForEpoch(null, 1).subscribe(response => {
console.log('called gtfe');
expect(response).toEqual(expectedResults, 'get epoch tiles');
});
const req = httpMock.expectOne(req => req.url === fakeConfigService.config.url + tilesService.endPoint + 'summary/epoch/1');
expect(req.request.method).toBe("GET");
req.flush(expectedResults);
httpMock.verify();
});
it('should get tile definition', () => {
let expectedResults = {
coarseCenterFrequenciesMHz: [],
phaseCentersDeg: []
} as TileDefinition;
tilesService.getTileDefinition(1).subscribe(response => {
expect(response).toEqual(expectedResults, 'get tile definition');
});
const req = httpMock.expectOne(fakeConfigService.config.url + tilesService.endPoint + '1/definitions');
expect(req.request.method).toBe("GET");
req.flush(expectedResults);
httpMock.verify();
});
});