2012-10-15 16:39:07 +08:00
|
|
|
describe('Circle', function () {
|
2015-10-10 02:23:09 +08:00
|
|
|
|
|
|
|
describe('#init', function () {
|
|
|
|
|
|
|
|
it('uses default radius if not given', function () {
|
|
|
|
var circle = L.circle([0, 0]);
|
|
|
|
expect(circle.getRadius()).to.eql(10);
|
|
|
|
});
|
|
|
|
|
2016-02-15 18:51:27 +08:00
|
|
|
it('throws error if radius is NaN', function () {
|
|
|
|
expect(function () {
|
|
|
|
L.circle([0, 0], NaN);
|
|
|
|
}).to.throwException('Circle radius cannot be NaN');
|
|
|
|
});
|
|
|
|
|
2015-10-10 02:23:09 +08:00
|
|
|
});
|
|
|
|
|
2012-10-15 16:39:07 +08:00
|
|
|
describe('#getBounds', function () {
|
|
|
|
|
2014-01-03 06:37:34 +08:00
|
|
|
var map, circle;
|
2012-10-15 16:39:07 +08:00
|
|
|
|
|
|
|
beforeEach(function () {
|
2014-01-03 06:37:34 +08:00
|
|
|
map = L.map(document.createElement('div')).setView([0, 0], 4);
|
2015-09-04 15:13:37 +08:00
|
|
|
circle = L.circle([50, 30], {radius: 200}).addTo(map);
|
2012-10-15 16:39:07 +08:00
|
|
|
});
|
|
|
|
|
2013-02-20 04:41:48 +08:00
|
|
|
it('returns bounds', function () {
|
2012-10-15 16:39:07 +08:00
|
|
|
var bounds = circle.getBounds();
|
|
|
|
|
2017-10-20 20:51:48 +08:00
|
|
|
expect(bounds.getSouthWest()).nearLatLng(new L.LatLng(49.99820, 29.99720));
|
|
|
|
expect(bounds.getNorthEast()).nearLatLng(new L.LatLng(50.00179, 30.00279));
|
2012-10-15 16:39:07 +08:00
|
|
|
});
|
|
|
|
});
|
2015-09-04 15:13:37 +08:00
|
|
|
|
|
|
|
describe('Legacy factory', function () {
|
|
|
|
|
|
|
|
var map, circle;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
map = L.map(document.createElement('div')).setView([0, 0], 4);
|
|
|
|
circle = L.circle([50, 30], 200).addTo(map);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns same bounds as 1.0 factory', function () {
|
|
|
|
var bounds = circle.getBounds();
|
|
|
|
|
2017-10-20 20:51:48 +08:00
|
|
|
expect(bounds.getSouthWest()).nearLatLng(new L.LatLng(49.99820, 29.99720));
|
|
|
|
expect(bounds.getNorthEast()).nearLatLng(new L.LatLng(50.00179, 30.00279));
|
2015-09-04 15:13:37 +08:00
|
|
|
});
|
|
|
|
});
|
2015-10-10 02:23:09 +08:00
|
|
|
|
2012-10-15 16:39:07 +08:00
|
|
|
});
|