2012-10-05 05:02:46 +08:00
|
|
|
describe("Map", function () {
|
2012-10-13 03:49:12 +08:00
|
|
|
describe("#whenReady", function () {
|
|
|
|
describe("when the map has not yet been loaded", function () {
|
|
|
|
it("calls the callback when the map is loaded", function () {
|
|
|
|
var map = L.map(document.createElement('div')),
|
|
|
|
spy = jasmine.createSpy();
|
|
|
|
|
|
|
|
map.whenReady(spy);
|
|
|
|
expect(spy).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
map.setView([0, 0], 1);
|
|
|
|
expect(spy).toHaveBeenCalled();
|
2012-12-12 07:01:37 +08:00
|
|
|
});
|
2012-10-13 03:49:12 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("when the map has already been loaded", function () {
|
|
|
|
it("calls the callback immediately", function () {
|
|
|
|
var map = L.map(document.createElement('div')),
|
|
|
|
spy = jasmine.createSpy();
|
|
|
|
|
|
|
|
map.setView([0, 0], 1);
|
|
|
|
map.whenReady(spy);
|
|
|
|
|
|
|
|
expect(spy).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-10-05 05:02:46 +08:00
|
|
|
describe("#getBounds", function () {
|
2012-12-12 07:01:37 +08:00
|
|
|
it("is safe to call from within a moveend callback during initial "
|
|
|
|
+ "load (#1027)", function () {
|
2012-10-05 05:02:46 +08:00
|
|
|
var c = document.createElement('div'),
|
|
|
|
map = L.map(c);
|
|
|
|
|
|
|
|
map.on("moveend", function () {
|
|
|
|
map.getBounds();
|
|
|
|
});
|
|
|
|
|
|
|
|
map.setView([51.505, -0.09], 13);
|
|
|
|
});
|
|
|
|
});
|
2012-12-12 07:17:36 +08:00
|
|
|
|
|
|
|
describe("#getMinZoom and #getMaxZoom", function () {
|
|
|
|
it("The minZoom and maxZoom options overrides any"
|
|
|
|
+ " minZoom and maxZoom set on layers", function () {
|
|
|
|
var c = document.createElement('div'),
|
|
|
|
map = L.map(c, { minZoom: 5, maxZoom: 10 });
|
|
|
|
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
|
|
|
L.tileLayer("{z}{x}{y}", { minZoom:5, maxZoom: 15 }).addTo(map);
|
|
|
|
expect(map.getMinZoom()).toBe(5);
|
|
|
|
expect(map.getMaxZoom()).toBe(10);
|
|
|
|
});
|
|
|
|
});
|
2012-10-05 05:02:46 +08:00
|
|
|
});
|