Skip to content

Commit

Permalink
Add tests for latLngToCoords
Browse files Browse the repository at this point in the history
  • Loading branch information
phloose committed May 20, 2020
1 parent a4a1caf commit 3d85364
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/suites/layer/GeoJSONSpec.js
Expand Up @@ -765,6 +765,32 @@ describe("L.GeoJSON functions", function () {
}
}
});
});

describe("#latLngToCoords", function () {
it("returns an array of coordinates (longitude, latitude)", function () {
const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0));
expect(coords).to.eql([0, 0]);
});

it("returns an array of coordinates and altitude (longitude, latitude, altitude)", function () {
const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0, 0));
expect(coords).to.eql([0, 0, 0]);
});

it("returns an array of coordinates with given precision (longitude, latitude)", function () {
const coords = L.GeoJSON.latLngToCoords(new L.LatLng(
1.123456, 1.123456
), 3);
expect(coords).to.eql([1.123, 1.123]);
});

it("returns an array of coordinates with given precision (longitude, latitude, altitude)", function () {
const coords = L.GeoJSON.latLngToCoords(new L.LatLng(
1.123456, 1.123456, 1.123456
), 3);
expect(coords).to.eql([1.123, 1.123, 1.123]);
});

});
});

0 comments on commit 3d85364

Please sign in to comment.