Start on some Polyline/Polygon tests.
This commit is contained in:
parent
3afee7eb49
commit
5873914062
@ -52,6 +52,8 @@
|
||||
<!-- /layer/vector/ -->
|
||||
<script type="text/javascript" src="suites/layer/vector/CircleSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/CircleMarkerSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolygonSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolylineSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolylineGeometrySpec.js"></script>
|
||||
|
||||
<!-- /map -->
|
||||
|
55
spec/suites/layer/vector/PolygonSpec.js
Normal file
55
spec/suites/layer/vector/PolygonSpec.js
Normal file
@ -0,0 +1,55 @@
|
||||
describe('Polygon', function() {
|
||||
|
||||
var c = document.createElement('div');
|
||||
c.style.width = '400px';
|
||||
c.style.height = '400px';
|
||||
var map = new L.Map(c);
|
||||
map.setView(new L.LatLng(55.8, 37.6), 6);
|
||||
|
||||
describe("#initialize", function() {
|
||||
it("doesn't overwrite the given latlng array", function () {
|
||||
var originalLatLngs = [
|
||||
[1, 2],
|
||||
[3, 4]
|
||||
];
|
||||
var sourceLatLngs = originalLatLngs.slice();
|
||||
|
||||
var polygon = new L.Polygon(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).toEqual(originalLatLngs);
|
||||
expect(polygon._latlngs).toNotEqual(sourceLatLngs);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#setLatLngs", function () {
|
||||
it("doesn't overwrite the given latlng array", function () {
|
||||
var originalLatLngs = [
|
||||
[1, 2],
|
||||
[3, 4]
|
||||
];
|
||||
var sourceLatLngs = originalLatLngs.slice();
|
||||
|
||||
var polygon = new L.Polygon(sourceLatLngs);
|
||||
|
||||
polygon.setLatLngs(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).toEqual(originalLatLngs);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#spliceLatLngs", function () {
|
||||
it("splices the internal latLngs", function () {
|
||||
var latLngs = [
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
[5, 6]
|
||||
];
|
||||
|
||||
var polygon = new L.Polygon(latLngs);
|
||||
|
||||
polygon.spliceLatLngs(1, 1, [7, 8]);
|
||||
|
||||
expect(polygon._latlngs).toEqual([L.latLng([1, 2]), L.latLng([7, 8]), L.latLng([5, 6])]);
|
||||
});
|
||||
});
|
||||
});
|
55
spec/suites/layer/vector/PolylineSpec.js
Normal file
55
spec/suites/layer/vector/PolylineSpec.js
Normal file
@ -0,0 +1,55 @@
|
||||
describe('Polyline', function() {
|
||||
|
||||
var c = document.createElement('div');
|
||||
c.style.width = '400px';
|
||||
c.style.height = '400px';
|
||||
var map = new L.Map(c);
|
||||
map.setView(new L.LatLng(55.8, 37.6), 6);
|
||||
|
||||
describe("#initialize", function() {
|
||||
it("doesn't overwrite the given latlng array", function () {
|
||||
var originalLatLngs = [
|
||||
[1, 2],
|
||||
[3, 4]
|
||||
];
|
||||
var sourceLatLngs = originalLatLngs.slice();
|
||||
|
||||
var polyline = new L.Polyline(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).toEqual(originalLatLngs);
|
||||
expect(polyline._latlngs).toNotEqual(sourceLatLngs);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#setLatLngs", function () {
|
||||
it("doesn't overwrite the given latlng array", function () {
|
||||
var originalLatLngs = [
|
||||
[1, 2],
|
||||
[3, 4]
|
||||
];
|
||||
var sourceLatLngs = originalLatLngs.slice();
|
||||
|
||||
var polyline = new L.Polyline(sourceLatLngs);
|
||||
|
||||
polyline.setLatLngs(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).toEqual(originalLatLngs);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#spliceLatLngs", function () {
|
||||
it("splices the internal latLngs", function () {
|
||||
var latLngs = [
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
[5, 6]
|
||||
];
|
||||
|
||||
var polyline = new L.Polyline(latLngs);
|
||||
|
||||
polyline.spliceLatLngs(1, 1, [7, 8]);
|
||||
|
||||
expect(polyline._latlngs).toEqual([L.latLng([1, 2]), L.latLng([7, 8]), L.latLng([5, 6])]);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user