2013-11-08 05:54:33 +08:00
|
|
|
describe('Polyline', function () {
|
2013-03-02 05:49:20 +08:00
|
|
|
|
2013-02-20 06:03:37 +08:00
|
|
|
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);
|
2013-03-02 05:49:20 +08:00
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
describe("#initialize", function () {
|
2013-02-20 06:03:37 +08:00
|
|
|
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);
|
|
|
|
|
2013-03-02 05:49:20 +08:00
|
|
|
expect(sourceLatLngs).to.eql(originalLatLngs);
|
|
|
|
expect(polyline._latlngs).to.not.eql(sourceLatLngs);
|
2013-02-20 06:03:37 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2013-03-02 05:49:20 +08:00
|
|
|
expect(sourceLatLngs).to.eql(originalLatLngs);
|
2013-02-20 06:03:37 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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]);
|
|
|
|
|
2013-03-02 05:49:20 +08:00
|
|
|
expect(polyline._latlngs).to.eql([L.latLng([1, 2]), L.latLng([7, 8]), L.latLng([5, 6])]);
|
2013-02-20 06:03:37 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|