Skip to content

Commit b4774a0

Browse files
committed
【fix】fix UT
1 parent 80bab9d commit b4774a0

File tree

1 file changed

+20
-54
lines changed

1 file changed

+20
-54
lines changed

test/openlayers/mapping/TileSuperMapRestSpec.js

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,90 +9,56 @@ import {
99
var url = GlobeParameter.imageURL;
1010
describe('openlayers_TileSuperMapRest', () => {
1111
var originalTimeout;
12-
var testDiv, map, tileOptions, tileSource;
13-
beforeAll(() => {
14-
testDiv = document.createElement("div");
15-
testDiv.setAttribute("id", "map");
16-
testDiv.style.styleFloat = "left";
17-
testDiv.style.marginLeft = "8px";
18-
testDiv.style.marginTop = "50px";
19-
testDiv.style.width = "500px";
20-
testDiv.style.height = "500px";
21-
document.body.appendChild(testDiv);
22-
//只测了serverType为iserver得情况
23-
new MapService(url).getMapInfo((serviceResult) => {
24-
map = new ol.Map({
25-
target: 'map',
26-
view: new ol.View({
27-
center: [12957388, 4853991],
28-
zoom: 11
29-
})
30-
});
31-
tileOptions = TileSuperMapRest.optionsFromMapJSON(url, serviceResult.result);
32-
tileSource = new TileSuperMapRest(tileOptions);
33-
var imageLayer = new ol.layer.Tile({
34-
source: tileSource
35-
});
36-
map.addLayer(imageLayer);
37-
});
38-
});
3912
beforeEach(() => {
4013
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
4114
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
4215
});
4316
afterEach(() => {
4417
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
4518
});
46-
afterAll(() => {
47-
document.body.removeChild(testDiv);
48-
});
4919

50-
it('initialize', (done) => {
51-
setTimeout(() => {
52-
try {
53-
expect(tileOptions).not.toBeNull();
54-
expect(tileOptions.serverType).toBe("ISERVER");
55-
expect(tileOptions.crossOrigin).toBe("anonymous");
56-
expect(tileSource).not.toBeNull();
57-
expect(tileSource.urls.length).toBe(1);
58-
done();
59-
} catch (exception) {
60-
console.log("'initialize'案例失败:" + exception.name + ":" + exception.message);
61-
expect(false).toBeTruthy();
62-
done();
20+
it('initialize', () => {
21+
var tileOptions = {
22+
url: url,
23+
prjCoordSys: {
24+
"epsgCode": 4326
6325
}
64-
}, 6000);
65-
26+
};
27+
var tileSource = new TileSuperMapRest(tileOptions);
28+
expect(tileSource.options).not.toBeNull();
29+
expect(tileSource.options.serverType).toBe("ISERVER");
30+
expect(tileSource.urls.length).toBe(1);
6631
});
6732

6833
it('tileUrlFunction', () => {
6934
var tempOptions = {
35+
url: url,
7036
extent: [0, 0, 90, 90],
7137
prjCoordSys: {
7238
"epsgCode": 4326
7339
}
7440
};
41+
var tileSourcetile = new TileSuperMapRest(tempOptions);
7542
var pixelRatio = "245";
7643
var coords = new ol.geom.Point(120.14, 30.24);
77-
var tileUrl = tileSource.tileUrlFunction(coords, pixelRatio, ol.proj.get("EPSG:4326"));
44+
var tileUrl = tileSourcetile.tileUrlFunction(coords, pixelRatio, ol.proj.get("EPSG:4326"));
7845
expect(tileUrl).not.toBeNull();
79-
expect(tileSource.getTileGrid().getTileSize()).toEqual(256);
80-
expect(tileSource.getTileGrid().getResolution(0)).toEqual(90.0 / 256);
46+
expect(tileSourcetile.getTileGrid().getTileSize()).toEqual(256);
47+
expect(tileSourcetile.getTileGrid().getResolution(0)).toEqual(90.0 / 256);
8148
});
8249

8350
it('tileUrlFunction_tilePoxy', () => {
84-
tileOptions.tileProxy = "tileProxy";
85-
var tileSourcetilePoxy = new TileSuperMapRest(tileOptions);
86-
var tempOptions = {
87-
redirect: true,
51+
var tileOptions = {
52+
url: url,
8853
prjCoordSys: {
8954
"epsgCode": 4326
90-
}
55+
},
56+
tileProxy : "tileProxy"
9157
};
58+
var tileSourcetilePoxy = new TileSuperMapRest(tileOptions);
9259
var pixelRatio = "245";
9360
var coords = new ol.geom.Point(120.14, 30.24);
9461
var tileUrl = tileSourcetilePoxy.tileUrlFunction(coords, pixelRatio, ol.proj.get("EPSG:4326"));
95-
// expect(tileUrl).toBe("tileProxyhttp%3A%2F%2Flocalhost%3A8090%2Fiserver%2Fservices%2Fmap-world%2Frest%2Fmaps%2F%25E4%25B8%2596%25E7%2595%258C%25E5%259C%25B0%25E5%259B%25BE_Day%2Fimage.png%3F%26transparent%3Dtrue%26cacheEnabled%3Dfalse%26width%3D256%26height%3D256%26viewBounds%3D%257B%2522leftBottom%2522%2520%3A%2520%257B%2522x%2522%3ANaN%2C%2522y%2522%3ANaN%257D%2C%2522rightTop%2522%2520%3A%2520%257B%2522x%2522%3ANaN%2C%2522y%2522%3ANaN%257D%257D");
9662
expect(tileUrl).not.toBeNull();
9763
});
9864

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy