forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseSpec.js
More file actions
122 lines (117 loc) · 2.98 KB
/
BaseSpec.js
File metadata and controls
122 lines (117 loc) · 2.98 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import '../../../src/leaflet/core/Base';
import L from "leaflet";
describe('Base', () => {
it("toGeoJSON precision", () => {
const p = L.marker([10.12345678912345, 4.12345678912345]);
expect(p.toGeoJSON().geometry.coordinates[0]).toEqual(4.12345678912345);
});
it("toGeoJSON toGeoJSONPrecision", () => {
L.toGeoJSONPrecision = 8;
const p = L.marker([10.12345678912345, 4.12345678912345]);
expect(p.toGeoJSON().geometry.coordinates[0]).toEqual(4.12345679);
});
it("expect crs latLngToPoint cache scale calculation", () => {
var scaleFn = spyOn(L.CRS.EPSG3857, 'scale').and.callThrough();
L.CRS.EPSG3857.latLngToPoint(L.latLng(50.5, 30.5), 2);
L.CRS.EPSG3857.latLngToPoint(L.latLng(50.3, 30.3), 2);
expect(scaleFn).toHaveBeenCalledTimes(1);
});
it("expect polyline getBounds will calc in use", () => {
const polyline = L.polyline([[10, 10], [20, 20]]);
expect(polyline.dirtyBounds).toBe(true);
polyline.getBounds();
expect(polyline.dirtyBounds).toBe(false);
});
it("expect geojson will cache feature default property in multiple adddata", () => {
var geojson = L.geoJSON();
var addLayerFn = spyOn(geojson, 'addLayer').and.callThrough();
geojson.addData([
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [102.0, 0.5]
},
"properties": {
"prop0": "value0"
}
},
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 2.0],
[103.0, 2.0]
]
},
"properties": {
"prop0": "value0"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0]]
]
},
"properties": {
"prop0": "value0"
}
}
]);
expect(addLayerFn).toHaveBeenCalledTimes(3);
geojson.addData([
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [102.0, 0.5]
},
"properties": {
"prop0": "value0"
}
},
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 2.0],
[103.0, 2.0]
]
},
"properties": {
"prop0": "value0"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0]]
]
},
"properties": {
"prop0": "value0"
}
}
]);
let count = 0;
geojson.eachLayer(function (layer) {
count++;
if (count > 3) {
expect(layer.hasOwnProperty('commonOptions')).toBe(true);
}
});
});
});