jshinting and major clean up of specs code, ref #2151

This commit is contained in:
Vladimir Agafonkin 2013-11-07 23:54:33 +02:00
parent 4f9e9a7c9a
commit 91c039b7aa
28 changed files with 328 additions and 301 deletions

25
spec/spec.hintrc.js Normal file
View File

@ -0,0 +1,25 @@
{
"browser": true,
"node": true,
"predef": ["define", "L", "expect", "describe", "it", "sinon", "happen", "beforeEach", "afterEach"],
"strict": false,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"forin": false,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"undef": true,
// "unused": true,
// "quotmark": "single",
"indent": 4,
"trailing": true,
"white": true,
"smarttabs": true
// "maxlen": 120
}

View File

@ -1,5 +1,5 @@
describe('L#noConflict', function() {
it('restores the previous L value and returns Leaflet namespace', function(){
describe('L#noConflict', function () {
it('restores the previous L value and returns Leaflet namespace', function () {
expect(L.version).to.be.ok();

View File

@ -1,42 +1,42 @@
function noSpecs() {
xit('has no specs');
}
if (!Array.prototype.map) {
Array.prototype.map = function(fun /*, thisp */) {
"use strict";
Array.prototype.map = function (fun /*, thisp */) {
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
if (this === void 0 || this === null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var t = Object(this);
// jshint bitwise: false
var len = t.length >>> 0;
if (typeof fun !== "function") {
throw new TypeError();
}
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t)
res[i] = fun.call(thisp, t[i], i, t);
}
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t) {
res[i] = fun.call(thisp, t[i], i, t);
}
}
return res;
};
return res;
};
}
expect.Assertion.prototype.near = function(expected, delta) {
delta = delta || 1;
expect(this.obj.x).to
.be.within(expected.x - delta, expected.x + delta);
expect(this.obj.y).to
.be.within(expected.y - delta, expected.y + delta);
expect.Assertion.prototype.near = function (expected, delta) {
delta = delta || 1;
expect(this.obj.x).to
.be.within(expected.x - delta, expected.x + delta);
expect(this.obj.y).to
.be.within(expected.y - delta, expected.y + delta);
};
expect.Assertion.prototype.nearLatLng = function(expected, delta) {
delta = delta || 1e-4;
expect(this.obj.lat).to
.be.within(expected.lat - delta, expected.lat + delta);
expect(this.obj.lng).to
.be.within(expected.lng - delta, expected.lng + delta);
};
expect.Assertion.prototype.nearLatLng = function (expected, delta) {
delta = delta || 1e-4;
expect(this.obj.lat).to
.be.within(expected.lat - delta, expected.lat + delta);
expect(this.obj.lng).to
.be.within(expected.lng - delta, expected.lng + delta);
};

View File

@ -12,7 +12,7 @@ describe("Control.Layers", function () {
spy = sinon.spy();
map.on('baselayerchange', spy)
.whenReady(function() {
.whenReady(function () {
happen.click(layers._baseLayersList.getElementsByTagName("input")[0]);
expect(spy.called).to.be.ok();

View File

@ -1,11 +1,11 @@
describe("Class", function() {
describe("Class", function () {
describe("#extend", function() {
describe("#extend", function () {
var Klass,
constructor,
method;
beforeEach(function() {
beforeEach(function () {
constructor = sinon.spy();
method = sinon.spy();
@ -19,7 +19,7 @@ describe("Class", function() {
});
});
it("creates a class with the given constructor & properties", function() {
it("creates a class with the given constructor & properties", function () {
var a = new Klass();
expect(constructor.called).to.be.ok();
@ -30,7 +30,7 @@ describe("Class", function() {
expect(method.called).to.be.ok();
});
it("inherits parent classes' constructor & properties", function() {
it("inherits parent classes' constructor & properties", function () {
var Klass2 = Klass.extend({baz: 2});
var b = new Klass2();
@ -46,28 +46,28 @@ describe("Class", function() {
expect(method.called).to.be.ok();
});
it("supports static properties", function() {
it("supports static properties", function () {
expect(Klass.bla).to.eql(1);
});
it("inherits parent static properties", function() {
it("inherits parent static properties", function () {
var Klass2 = Klass.extend({});
expect(Klass2.bla).to.eql(1);
});
it("overrides parent static properties", function() {
it("overrides parent static properties", function () {
var Klass2 = Klass.extend({statics: {bla: 2}});
expect(Klass2.bla).to.eql(2);
});
it("includes the given mixin", function() {
it("includes the given mixin", function () {
var a = new Klass();
expect(a.mixin).to.be.ok();
});
it("includes multiple mixins", function() {
it("includes multiple mixins", function () {
var Klass2 = L.Class.extend({
includes: [{mixin: true}, {mixin2: true}]
});
@ -77,14 +77,14 @@ describe("Class", function() {
expect(a.mixin2).to.be.ok();
});
it("grants the ability to include the given mixin", function() {
it("grants the ability to include the given mixin", function () {
Klass.include({mixin2: true});
var a = new Klass();
expect(a.mixin2).to.be.ok();
});
it("merges options instead of replacing them", function() {
it("merges options instead of replacing them", function () {
var KlassWithOptions1 = L.Class.extend({
options: {
foo1: 1,

View File

@ -1,21 +1,21 @@
describe('Events', function() {
describe('Events', function () {
var Klass;
beforeEach(function() {
beforeEach(function () {
Klass = L.Class.extend({
includes: L.Mixin.Events
});
});
describe('#fireEvent', function() {
describe('#fireEvent', function () {
it('fires all listeners added through #addEventListener', function() {
it('fires all listeners added through #addEventListener', function () {
var obj = new Klass(),
spy1 = sinon.spy(),
spy2 = sinon.spy(),
spy3 = sinon.spy(),
spy4 = sinon.spy(),
spy5 = sinon.spy();
spy5 = sinon.spy(),
spy6 = sinon.spy();
obj.addEventListener('test', spy1);
@ -42,7 +42,7 @@ describe('Events', function() {
expect(spy6.callCount).to.be(1);
});
it('provides event object to listeners and executes them in the right context', function() {
it('provides event object to listeners and executes them in the right context', function () {
var obj = new Klass(),
obj2 = new Klass(),
obj3 = new Klass(),
@ -88,7 +88,7 @@ describe('Events', function() {
obj4.fireEvent('test', {baz: 4});
});
it('calls no listeners removed through #removeEventListener', function() {
it('calls no listeners removed through #removeEventListener', function () {
var obj = new Klass(),
spy = sinon.spy(),
spy2 = sinon.spy(),
@ -171,7 +171,7 @@ describe('Events', function() {
expect(spy2.called).to.be(true);
});
it('removes listeners with a stamp originally added without one', function() {
it('removes listeners with a stamp originally added without one', function () {
var obj = new Klass(),
spy1 = sinon.spy(),
spy2 = sinon.spy(),
@ -252,24 +252,25 @@ describe('Events', function() {
//Add and remove a listener
obj.addEventListener('test', spy, foo2);
obj.removeEventListener('test', spy, foo2);
expect(obj.hasEventListeners('test')).to.be(false);
});
it('makes sure an event is not triggered if a listener is removed during dispatch',function() {
it('makes sure an event is not triggered if a listener is removed during dispatch', function () {
var obj = new Klass(),
spy = sinon.spy();
obj.addEventListener('test', function() { obj.removeEventListener('test',spy); });
obj.addEventListener('test', spy);
obj.fireEvent('test');
obj.addEventListener('test', function () { obj.removeEventListener('test', spy); });
obj.addEventListener('test', spy);
obj.fireEvent('test');
expect(spy.called).to.be(false);
});
});
describe('#on, #off & #fire', function() {
describe('#on, #off & #fire', function () {
it('works like #addEventListener && #removeEventListener', function() {
it('works like #addEventListener && #removeEventListener', function () {
var obj = new Klass(),
spy = sinon.spy();
@ -284,7 +285,7 @@ describe('Events', function() {
expect(spy.callCount).to.be.lessThan(2);
});
it('does not override existing methods with the same name', function() {
it('does not override existing methods with the same name', function () {
var spy1 = sinon.spy(),
spy2 = sinon.spy(),
spy3 = sinon.spy();
@ -309,10 +310,10 @@ describe('Events', function() {
});
});
describe("#clearEventListeners", function() {
it("clears all registered listeners on an object", function() {
describe("#clearEventListeners", function () {
it("clears all registered listeners on an object", function () {
var spy = sinon.spy(),
obj = new Klass()
obj = new Klass(),
otherObj = new Klass();
obj.on('test', spy, obj);
@ -326,8 +327,8 @@ describe('Events', function() {
});
});
describe('#once', function() {
it('removes event listeners after first trigger', function() {
describe('#once', function () {
it('removes event listeners after first trigger', function () {
var obj = new Klass(),
spy = sinon.spy();
@ -341,7 +342,7 @@ describe('Events', function() {
expect(spy.callCount).to.be.lessThan(2);
});
it('works with an object hash', function() {
it('works with an object hash', function () {
var obj = new Klass(),
spy = sinon.spy(),
otherSpy = sinon.spy();
@ -376,7 +377,7 @@ describe('Events', function() {
expect(spy.called).to.be(false);
});
it('works if called from a context that doesnt implement #Events', function() {
it('works if called from a context that doesnt implement #Events', function () {
var obj = new Klass(),
spy = sinon.spy(),
foo = {};

View File

@ -242,15 +242,15 @@ describe('Util', function () {
it('throws when a template token is not given', function () {
expect(function () {
L.Util.template(tpl, {foo: 'bar'});
L.Util.template(undefined, {foo: 'bar'});
}).to.throwError();
});
});
describe('#isArray', function () {
expect(L.Util.isArray([1, 2, 3])).to.be.true;
expect(L.Util.isArray(new Array(1, 2, 3))).to.be.true;
expect(L.Util.isArray('blabla')).to.be.false;
expect(L.Util.isArray({0: 1, 1: 2})).to.be.false;
expect(L.Util.isArray([1, 2, 3])).to.be(true);
expect(L.Util.isArray(new Array(1, 2, 3))).to.be(true);
expect(L.Util.isArray('blabla')).to.be(false);
expect(L.Util.isArray({0: 1, 1: 2})).to.be(false);
});
});

View File

@ -1,10 +1,10 @@
describe('DomEvent', function() {
describe('DomEvent', function () {
var el;
function simulateClick(el) {
if (document.createEvent) {
var e = document.createEvent('MouseEvents');
e.initMouseEvent('click', true, true, window,
e.initMouseEvent('click', true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
return el.dispatchEvent(e);
} else if (el.fireEvent) {
@ -12,19 +12,19 @@ describe('DomEvent', function() {
}
}
beforeEach(function() {
beforeEach(function () {
el = document.createElement('div');
el.style.position = 'absolute';
el.style.top = el.style.left = '-10000px';
document.body.appendChild(el);
});
afterEach(function() {
afterEach(function () {
document.body.removeChild(el);
});
describe('#addListener', function() {
it('adds a listener and calls it on event', function() {
describe('#addListener', function () {
it('adds a listener and calls it on event', function () {
var listener1 = sinon.spy(),
listener2 = sinon.spy();
@ -37,11 +37,11 @@ describe('DomEvent', function() {
expect(listener2.called).to.be.ok();
});
it('binds "this" to the given context', function() {
it('binds "this" to the given context', function () {
var obj = {foo: 'bar'},
result;
L.DomEvent.addListener(el, 'click', function() {
L.DomEvent.addListener(el, 'click', function () {
result = this;
}, obj);
@ -50,10 +50,10 @@ describe('DomEvent', function() {
expect(result).to.eql(obj);
});
it('passes an event object to the listener', function() {
it('passes an event object to the listener', function () {
var type;
L.DomEvent.addListener(el, 'click', function(e) {
L.DomEvent.addListener(el, 'click', function (e) {
type = e && e.type;
});
simulateClick(el);
@ -62,8 +62,8 @@ describe('DomEvent', function() {
});
});
describe('#removeListener', function() {
it('removes a previously added listener', function() {
describe('#removeListener', function () {
it('removes a previously added listener', function () {
var listener = sinon.spy();
L.DomEvent.addListener(el, 'click', listener);
@ -75,8 +75,8 @@ describe('DomEvent', function() {
});
});
describe('#stopPropagation', function() {
it('stops propagation of the given event', function() {
describe('#stopPropagation', function () {
it('stops propagation of the given event', function () {
var child = document.createElement('div'),
listener = sinon.spy();
@ -92,8 +92,8 @@ describe('DomEvent', function() {
el.removeChild(child);
});
});
describe('#preventDefault', function() {
it('prevents the default action of event', function() {
describe('#preventDefault', function () {
it('prevents the default action of event', function () {
L.DomEvent.addListener(el, 'click', L.DomEvent.preventDefault);
expect(simulateClick(el)).to.be(false);

View File

@ -1,30 +1,30 @@
describe('DomUtil', function() {
describe('DomUtil', function () {
var el;
beforeEach(function() {
beforeEach(function () {
el = document.createElement('div');
el.style.position = 'absolute';
el.style.top = el.style.left = '-10000px';
document.body.appendChild(el);
});
afterEach(function() {
afterEach(function () {
document.body.removeChild(el);
});
describe('#get', function() {
it('gets element by id if the given argument is string', function() {
describe('#get', function () {
it('gets element by id if the given argument is string', function () {
el.id = 'testId';
expect(L.DomUtil.get(el.id)).to.eql(el);
});
it('returns the element if it is given as an argument', function() {
it('returns the element if it is given as an argument', function () {
expect(L.DomUtil.get(el)).to.eql(el);
});
});
describe('#addClass, #removeClass, #hasClass', function() {
it('has defined class for test element', function() {
describe('#addClass, #removeClass, #hasClass', function () {
it('has defined class for test element', function () {
el.className = 'bar foo baz ';
expect(L.DomUtil.hasClass(el, 'foo')).to.be.ok();
expect(L.DomUtil.hasClass(el, 'bar')).to.be.ok();
@ -32,7 +32,7 @@ describe('DomUtil', function() {
expect(L.DomUtil.hasClass(el, 'boo')).to.not.be.ok();
});
it('adds or removes the class', function() {
it('adds or removes the class', function () {
el.className = '';
L.DomUtil.addClass(el, 'foo');

View File

@ -1,23 +1,23 @@
describe('PosAnimation', function() {
describe('PosAnimation', function () {
var el;
beforeEach(function() {
beforeEach(function () {
el = document.createElement('div');
this.subject = new L.PosAnimation();
this.subject._el = el;
});
describe('#_onStep', function() {
it("sets element position and fires step event if it is able to get current position", function() {
describe('#_onStep', function () {
it("sets element position and fires step event if it is able to get current position", function () {
var point = new L.Point(5, 5, true);
sinon.stub(this.subject, '_getPos').returns(point);
this.subject.fire = sinon.stub();
this.subject._onStep();
expect(this.subject.fire.withArgs('step').calledOnce).to.be(true);
expect(this.subject._el._leaflet_pos).to.be(point);
expect(L.DomUtil.getPosition(this.subject._el)).to.be(point);
});
it('stops transition if a position returned', function() {
it('stops transition if a position returned', function () {
sinon.stub(this.subject, '_onTransitionEnd');
sinon.stub(this.subject, '_getPos').returns(undefined);
this.subject._onStep();

View File

@ -1,47 +1,47 @@
describe("CRS.EPSG3395", function() {
describe("CRS.EPSG3395", function () {
var crs = L.CRS.EPSG3395;
describe("#latLngToPoint", function() {
it("projects a center point", function() {
describe("#latLngToPoint", function () {
it("projects a center point", function () {
expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
})
});
it("projects the northeast corner of the world", function() {
it("projects the northeast corner of the world", function () {
expect(crs.latLngToPoint(L.latLng(85.0840591556, 180), 0)).near(new L.Point(256, 0));
});
});
describe("#pointToLatLng", function() {
it("reprojects a center point", function() {
describe("#pointToLatLng", function () {
it("reprojects a center point", function () {
expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
})
});
it("reprojects the northeast corner of the world", function() {
it("reprojects the northeast corner of the world", function () {
expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0840591556, 180));
});
});
});
describe("CRS.EPSG3857", function() {
describe("CRS.EPSG3857", function () {
var crs = L.CRS.EPSG3857;
describe("#latLngToPoint", function() {
it("projects a center point", function() {
describe("#latLngToPoint", function () {
it("projects a center point", function () {
expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
})
});
it("projects the northeast corner of the world", function() {
it("projects the northeast corner of the world", function () {
expect(crs.latLngToPoint(L.latLng(85.0511287798, 180), 0)).near(new L.Point(256, 0));
});
});
describe("#pointToLatLng", function() {
it("reprojects a center point", function() {
describe("#pointToLatLng", function () {
it("reprojects a center point", function () {
expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
})
});
it("reprojects the northeast corner of the world", function() {
it("reprojects the northeast corner of the world", function () {
expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0511287798, 180));
});
});
});
});

View File

@ -1,7 +1,7 @@
describe('LatLngBounds', function() {
describe('LatLngBounds', function () {
var a, c;
beforeEach(function() {
beforeEach(function () {
a = new L.LatLngBounds(
new L.LatLng(14, 12),
new L.LatLng(30, 40));
@ -62,62 +62,62 @@ describe('LatLngBounds', function() {
});
});
describe('#isValid', function() {
it('returns true if properly set up', function() {
describe('#isValid', function () {
it('returns true if properly set up', function () {
expect(a.isValid()).to.be.ok();
});
it('returns false if is invalid', function() {
it('returns false if is invalid', function () {
expect(c.isValid()).to.not.be.ok();
});
it('returns true if extended', function() {
it('returns true if extended', function () {
c.extend([0, 0]);
expect(c.isValid()).to.be.ok();
});
});
describe('#getWest', function () {
it('returns a proper bbox west value', function() {
it('returns a proper bbox west value', function () {
expect(a.getWest()).to.eql(12);
});
});
describe('#getSouth', function () {
it('returns a proper bbox south value', function() {
it('returns a proper bbox south value', function () {
expect(a.getSouth()).to.eql(14);
});
});
describe('#getEast', function () {
it('returns a proper bbox east value', function() {
it('returns a proper bbox east value', function () {
expect(a.getEast()).to.eql(40);
});
});
describe('#getNorth', function () {
it('returns a proper bbox north value', function() {
it('returns a proper bbox north value', function () {
expect(a.getNorth()).to.eql(30);
});
});
describe('#toBBoxString', function () {
it('returns a proper left,bottom,right,top bbox', function() {
it('returns a proper left,bottom,right,top bbox', function () {
expect(a.toBBoxString()).to.eql("12,14,40,30");
});
});
describe('#getNorthWest', function () {
it('returns a proper north-west LatLng', function() {
it('returns a proper north-west LatLng', function () {
expect(a.getNorthWest()).to.eql(new L.LatLng(a.getNorth(), a.getWest()));
});
});
describe('#getSouthEast', function () {
it('returns a proper south-east LatLng', function() {
it('returns a proper south-east LatLng', function () {
expect(a.getSouthEast()).to.eql(new L.LatLng(a.getSouth(), a.getEast()));
});
});

View File

@ -1,6 +1,6 @@
describe('LatLng', function() {
describe('constructor', function() {
it("sets lat and lng", function() {
describe('LatLng', function () {
describe('constructor', function () {
it("sets lat and lng", function () {
var a = new L.LatLng(25, 74);
expect(a.lat).to.eql(25);
expect(a.lng).to.eql(74);
@ -15,30 +15,30 @@ describe('LatLng', function() {
var a = new L.LatLng(NaN, NaN);
}).to.throwError();
});
it ('does not set altitude if undefined', function () {
it('does not set altitude if undefined', function () {
var a = new L.LatLng(25, 74);
expect(typeof a.alt).to.eql('undefined');
});
it ('sets altitude', function () {
it('sets altitude', function () {
var a = new L.LatLng(25, 74, 50);
expect(a.alt).to.eql(50);
var b = new L.LatLng(-25, -74, -50);
expect(b.alt).to.eql(-50);
});
});
describe('#equals', function() {
it("returns true if compared objects are equal within a certain margin", function() {
describe('#equals', function () {
it("returns true if compared objects are equal within a certain margin", function () {
var a = new L.LatLng(10, 20);
var b = new L.LatLng(10 + 1.0E-10, 20 - 1.0E-10);
expect(a.equals(b)).to.eql(true);
});
it("returns false if compared objects are not equal within a certain margin", function() {
it("returns false if compared objects are not equal within a certain margin", function () {
var a = new L.LatLng(10, 20);
var b = new L.LatLng(10, 23.3);
expect(a.equals(b)).to.eql(false);
@ -51,7 +51,7 @@ describe('LatLng', function() {
});
describe('#wrap', function () {
it("wraps longitude to lie between -180 and 180 by default", function() {
it("wraps longitude to lie between -180 and 180 by default", function () {
var a = new L.LatLng(0, 190).wrap().lng;
expect(a).to.eql(-170);
@ -77,7 +77,7 @@ describe('LatLng', function() {
expect(h).to.eql(180);
});
it("wraps longitude within the given range", function() {
it("wraps longitude within the given range", function () {
var a = new L.LatLng(0, 190).wrap(-100, 100).lng;
expect(a).to.eql(-10);
});

View File

@ -1,39 +1,39 @@
describe("Projection.Mercator", function() {
describe("Projection.Mercator", function () {
var p = L.Projection.Mercator;
describe("#project", function() {
it("projects a center point", function() {
describe("#project", function () {
it("projects a center point", function () {
//edge cases
expect(p.project(new L.LatLng(0, 0))).near(new L.Point(0, 0));
});
it("projects the northeast corner of the world", function() {
it("projects the northeast corner of the world", function () {
expect(p.project(new L.LatLng(90, 180))).near(new L.Point(20037508, 20037508));
});
it("projects the southwest corner of the world", function() {
it("projects the southwest corner of the world", function () {
expect(p.project(new L.LatLng(-90, -180))).near(new L.Point(-20037508, -20037508));
});
it("projects other points", function() {
expect(p.project(new L.LatLng(50, 30))).near(new L.Point(3339584, 6413524));
it("projects other points", function () {
expect(p.project(new L.LatLng(50, 30))).near(new L.Point(3339584, 6413524));
// from https://github.com/Leaflet/Leaflet/issues/1578
expect(p.project(new L.LatLng(51.9371170300465, 80.11230468750001)))
.near(new L.Point(8918060.964088084, 6755099.410887127));
// from https://github.com/Leaflet/Leaflet/issues/1578
expect(p.project(new L.LatLng(51.9371170300465, 80.11230468750001)))
.near(new L.Point(8918060.964088084, 6755099.410887127));
});
});
describe("#unproject", function() {
describe("#unproject", function () {
function pr(point) {
return p.project(p.unproject(point));
}
it("unprojects a center point", function() {
it("unprojects a center point", function () {
expect(pr(new L.Point(0, 0))).near(new L.Point(0, 0));
});
it("unprojects pi points", function() {
it("unprojects pi points", function () {
expect(pr(new L.Point(-Math.PI, Math.PI))).near(new L.Point(-Math.PI, Math.PI));
expect(pr(new L.Point(-Math.PI, -Math.PI))).near(new L.Point(-Math.PI, -Math.PI));

View File

@ -1,7 +1,7 @@
describe('Bounds', function() {
describe('Bounds', function () {
var a, b, c;
beforeEach(function() {
beforeEach(function () {
a = new L.Bounds(
new L.Point(14, 12),
new L.Point(30, 40));
@ -13,19 +13,19 @@ describe('Bounds', function() {
c = new L.Bounds();
});
describe('constructor', function() {
it('creates bounds with proper min & max on (Point, Point)', function() {
describe('constructor', function () {
it('creates bounds with proper min & max on (Point, Point)', function () {
expect(a.min).to.eql(new L.Point(14, 12));
expect(a.max).to.eql(new L.Point(30, 40));
});
it('creates bounds with proper min & max on (Point[])', function() {
it('creates bounds with proper min & max on (Point[])', function () {
expect(b.min).to.eql(new L.Point(14, 12));
expect(b.max).to.eql(new L.Point(30, 40));
});
});
describe('#extend', function() {
it('extends the bounds to contain the given point', function() {
describe('#extend', function () {
it('extends the bounds to contain the given point', function () {
a.extend(new L.Point(50, 20));
expect(a.min).to.eql(new L.Point(14, 12));
expect(a.max).to.eql(new L.Point(50, 40));
@ -36,14 +36,14 @@ describe('Bounds', function() {
});
});
describe('#getCenter', function() {
it('returns the center point', function() {
describe('#getCenter', function () {
it('returns the center point', function () {
expect(a.getCenter()).to.eql(new L.Point(22, 26));
});
});
describe('#contains', function() {
it('contains other bounds or point', function() {
describe('#contains', function () {
it('contains other bounds or point', function () {
a.extend(new L.Point(50, 10));
expect(a.contains(b)).to.be.ok();
expect(b.contains(a)).to.not.be.ok();
@ -52,14 +52,14 @@ describe('Bounds', function() {
});
});
describe('#isValid', function() {
it('returns true if properly set up', function() {
describe('#isValid', function () {
it('returns true if properly set up', function () {
expect(a.isValid()).to.be.ok();
});
it('returns false if is invalid', function() {
it('returns false if is invalid', function () {
expect(c.isValid()).to.not.be.ok();
});
it('returns true if extended', function() {
it('returns true if extended', function () {
c.extend([0, 0]);
expect(c.isValid()).to.be.ok();
});

View File

@ -1,42 +1,42 @@
describe("Point", function() {
describe("Point", function () {
describe('constructor', function() {
describe('constructor', function () {
it("creates a point with the given x and y", function() {
it("creates a point with the given x and y", function () {
var p = new L.Point(1.5, 2.5);
expect(p.x).to.eql(1.5);
expect(p.y).to.eql(2.5);
});
it("rounds the given x and y if the third argument is true", function() {
it("rounds the given x and y if the third argument is true", function () {
var p = new L.Point(1.3, 2.7, true);
expect(p.x).to.eql(1);
expect(p.y).to.eql(3);
});
});
describe('#subtract', function() {
it('subtracts the given point from this one', function() {
describe('#subtract', function () {
it('subtracts the given point from this one', function () {
var a = new L.Point(50, 30),
b = new L.Point(20, 10);
expect(a.subtract(b)).to.eql(new L.Point(30, 20));
});
});
describe('#add', function() {
it('adds given point to this one', function() {
describe('#add', function () {
it('adds given point to this one', function () {
expect(new L.Point(50, 30).add(new L.Point(20, 10))).to.eql(new L.Point(70, 40));
});
});
describe('#divideBy', function() {
it('divides this point by the given amount', function() {
describe('#divideBy', function () {
it('divides this point by the given amount', function () {
expect(new L.Point(50, 30).divideBy(5)).to.eql(new L.Point(10, 6));
});
});
describe('#multiplyBy', function() {
it('multiplies this point by the given amount', function() {
describe('#multiplyBy', function () {
it('multiplies this point by the given amount', function () {
expect(new L.Point(50, 30).multiplyBy(2)).to.eql(new L.Point(100, 60));
});
});

View File

@ -1,13 +1,13 @@
describe("Transformation", function() {
describe("Transformation", function () {
var t, p;
beforeEach(function() {
beforeEach(function () {
t = new L.Transformation(1, 2, 3, 4);
p = new L.Point(10, 20);
});
describe('#transform', function () {
it("performs a transformation", function() {
it("performs a transformation", function () {
var p2 = t.transform(p, 2);
expect(p2).to.eql(new L.Point(24, 128));
});
@ -18,7 +18,7 @@ describe("Transformation", function() {
});
describe('#untransform', function () {
it("performs a reverse transformation", function() {
it("performs a reverse transformation", function () {
var p2 = t.transform(p, 2);
var p3 = t.untransform(p2, 2);
expect(p3).to.eql(p);

View File

@ -17,22 +17,25 @@
fg1.addLayer(marker);
fg2.addLayer(marker);
var wasClicked = 0;
fg2.on('click', function(e) {
var wasClicked1,
wasClicked2;
fg2.on('click', function (e) {
expect(e.layer).to.be(marker);
expect(e.target).to.be(fg2);
wasClicked |= 1;
wasClicked2 = true;
});
fg1.on('click', function (e) {
expect(e.layer).to.be(marker);
expect(e.target).to.be(fg1);
wasClicked |= 2;
wasClicked1 = true;
});
marker.fire('click', { type: 'click' });
expect(wasClicked).to.be(3);
expect(wasClicked1).to.be(true);
expect(wasClicked2).to.be(true);
});
});
});
@ -76,7 +79,7 @@
fg.addLayer(marker);
expect(fg.hasLayer(marker)).to.be(true);
fg.removeLayer(marker._leaflet_id);
fg.removeLayer(L.stamp(marker));
expect(fg.hasLayer(marker)).to.be(false);
});
});

View File

@ -210,7 +210,7 @@ describe("L.LayerGroup#toGeoJSON", function () {
return {
type: 'Point',
coordinates: [20, 10]
}
};
};
expect(layerGroup.toGeoJSON()).to.eql({

View File

@ -1,6 +1,6 @@
describe('LayerGroup', function () {
describe("#addLayer", function () {
it('adds a layer', function() {
it('adds a layer', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]);
@ -10,7 +10,7 @@
});
});
describe("#removeLayer", function () {
it('removes a layer', function() {
it('removes a layer', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]);
@ -21,7 +21,7 @@
});
});
describe("#clearLayers", function () {
it('removes all layers', function() {
it('removes all layers', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]);
@ -32,7 +32,7 @@
});
});
describe("#getLayers", function () {
it('gets all layers', function() {
it('gets all layers', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]);
@ -42,14 +42,14 @@
});
});
describe("#eachLayer", function () {
it('iterates over all layers', function() {
it('iterates over all layers', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]),
ctx = { foo: 'bar' };
lg.addLayer(marker);
lg.eachLayer(function(layer) {
lg.eachLayer(function (layer) {
expect(layer).to.eql(marker);
expect(this).to.eql(ctx);
}, ctx);

View File

@ -1,4 +1,4 @@
describe('Popup', function() {
describe('Popup', function () {
var c, map;
@ -10,7 +10,7 @@ describe('Popup', function() {
map.setView(new L.LatLng(55.8, 37.6), 6);
});
it("closes on map click when map has closePopupOnClick option", function() {
it("closes on map click when map has closePopupOnClick option", function () {
map.options.closePopupOnClick = true;
var popup = new L.Popup()
@ -22,7 +22,7 @@ describe('Popup', function() {
expect(map.hasLayer(popup)).to.be(false);
});
it("closes on map click when popup has closeOnClick option", function() {
it("closes on map click when popup has closeOnClick option", function () {
map.options.closePopupOnClick = false;
var popup = new L.Popup({closeOnClick: true})
@ -34,7 +34,7 @@ describe('Popup', function() {
expect(map.hasLayer(popup)).to.be(false);
});
it("does not close on map click when popup has closeOnClick: false option", function() {
it("does not close on map click when popup has closeOnClick: false option", function () {
map.options.closePopupOnClick = true;
var popup = new L.Popup({closeOnClick: false})
@ -46,7 +46,7 @@ describe('Popup', function() {
expect(map.hasLayer(popup)).to.be(true);
});
it("toggles its visibility when marker is clicked", function() {
it("toggles its visibility when marker is clicked", function () {
var marker = new L.Marker(new L.LatLng(55.8, 37.6));
map.addLayer(marker);
@ -70,7 +70,7 @@ describe('Popup', function() {
marker.closePopup.restore();
});
it("should trigger popupopen on marker when popup opens", function() {
it("should trigger popupopen on marker when popup opens", function () {
var marker1 = new L.Marker(new L.LatLng(55.8, 37.6));
var marker2 = new L.Marker(new L.LatLng(57.123076977278, 44.861962891635));
@ -91,7 +91,7 @@ describe('Popup', function() {
expect(spy.called).to.be(true);
});
it("should trigger popupclose on marker when popup closes", function() {
it("should trigger popupclose on marker when popup closes", function () {
var marker1 = new L.Marker(new L.LatLng(55.8, 37.6));
var marker2 = new L.Marker(new L.LatLng(57.123076977278, 44.861962891635));

View File

@ -11,7 +11,8 @@ describe('TileLayer', function () {
it("has the same zoomlevels as the tilelayer", function () {
var maxZoom = 10,
minZoom = 5;
map.setView([0, 0], 1);
map.setView([0, 0], 1);
L.tileLayer(tileUrl, {
maxZoom: maxZoom,
@ -36,33 +37,32 @@ describe('TileLayer', function () {
it("has its zoomlevels updated to fit the new layer", function () {
map.setView([0, 0], 1);
L.tileLayer(tileUrl, { minZoom:10, maxZoom: 15 }).addTo(map);
L.tileLayer(tileUrl, {minZoom: 10, maxZoom: 15}).addTo(map);
expect(map.getMinZoom()).to.be(10);
expect(map.getMaxZoom()).to.be(15);
L.tileLayer(tileUrl, { minZoom:5, maxZoom: 10 }).addTo(map);
L.tileLayer(tileUrl, {minZoom: 5, maxZoom: 10}).addTo(map);
expect(map.getMinZoom()).to.be(5); // changed
expect(map.getMaxZoom()).to.be(15); // unchanged
L.tileLayer(tileUrl,{ minZoom:10, maxZoom: 20 }).addTo(map);
L.tileLayer(tileUrl, {minZoom: 10, maxZoom: 20}).addTo(map);
expect(map.getMinZoom()).to.be(5); // unchanged
expect(map.getMaxZoom()).to.be(20); // changed
L.tileLayer(tileUrl, { minZoom:0, maxZoom: 25 }).addTo(map);
L.tileLayer(tileUrl, {minZoom: 0, maxZoom: 25}).addTo(map);
expect(map.getMinZoom()).to.be(0); // changed
expect(map.getMaxZoom()).to.be(25); // changed
});
});
describe("when a tilelayer is removed from a map", function () {
it("has its zoomlevels updated to only fit the layers it currently has", function () {
var tiles = [ L.tileLayer(tileUrl, { minZoom:10, maxZoom: 15 }).addTo(map),
L.tileLayer(tileUrl, { minZoom:5, maxZoom: 10 }).addTo(map),
L.tileLayer(tileUrl, { minZoom:10, maxZoom: 20 }).addTo(map),
L.tileLayer(tileUrl, { minZoom:0, maxZoom: 25 }).addTo(map)
var tiles = [ L.tileLayer(tileUrl, {minZoom: 10, maxZoom: 15}).addTo(map),
L.tileLayer(tileUrl, {minZoom: 5, maxZoom: 10}).addTo(map),
L.tileLayer(tileUrl, {minZoom: 10, maxZoom: 20}).addTo(map),
L.tileLayer(tileUrl, {minZoom: 0, maxZoom: 25}).addTo(map)
];
map.whenReady(function() {
map.whenReady(function () {
expect(map.getMinZoom()).to.be(0);
expect(map.getMaxZoom()).to.be(25);

View File

@ -1,13 +1,13 @@
describe('CircleMarker', function() {
describe("#_radius", function() {
describe('CircleMarker', function () {
describe("#_radius", function () {
var map;
beforeEach(function() {
beforeEach(function () {
map = L.map(document.createElement('div'));
map.setView([0, 0], 1);
});
describe("when a CircleMarker is added to the map ", function() {
describe("with a radius set as an option", function() {
it("takes that radius", function() {
describe("when a CircleMarker is added to the map ", function () {
describe("with a radius set as an option", function () {
it("takes that radius", function () {
var marker = L.circleMarker([0, 0], { radius: 20 }).addTo(map);
expect(marker._radius).to.be(20);
@ -33,7 +33,7 @@
});
describe("and setStyle is used to change the radius after adding", function () {
it("takes the given radius", function() {
it("takes the given radius", function () {
var marker = L.circleMarker([0, 0], { radius: 20 });
marker.addTo(map);
marker.setStyle({ radius: 15 });

View File

@ -1,4 +1,4 @@
describe('Polygon', function() {
describe('Polygon', function () {
var c = document.createElement('div');
c.style.width = '400px';
@ -6,7 +6,7 @@ describe('Polygon', function() {
var map = new L.Map(c);
map.setView(new L.LatLng(55.8, 37.6), 6);
describe("#initialize", function() {
describe("#initialize", function () {
it("doesn't overwrite the given latlng array", function () {
var originalLatLngs = [
[1, 2],
@ -24,7 +24,7 @@ describe('Polygon', function() {
var polygon = new L.Polygon([]);
expect(polygon.getLatLngs()).to.eql([]);
});
it("can be initialized with holes", function () {
var originalLatLngs = [
[ //external rink
@ -38,7 +38,7 @@ describe('Polygon', function() {
//getLatLngs() returns only external ring
expect(polygon.getLatLngs()).to.eql([L.latLng([0, 10]), L.latLng([10, 10]), L.latLng([10, 0])]);
})
});
});
describe("#setLatLngs", function () {
@ -55,8 +55,8 @@ describe('Polygon', function() {
expect(sourceLatLngs).to.eql(originalLatLngs);
});
it("can be set external ring and holes", function() {
it("can be set external ring and holes", function () {
var latLngs = [
[ //external rink
[0, 10], [10, 10], [10, 0]
@ -70,7 +70,7 @@ describe('Polygon', function() {
//getLatLngs() returns only external ring
expect(polygon.getLatLngs()).to.eql([L.latLng([0, 10]), L.latLng([10, 10]), L.latLng([10, 0])]);
})
});
});
describe("#spliceLatLngs", function () {

View File

@ -1,4 +1,4 @@
describe('PolylineGeometry', function() {
describe('PolylineGeometry', function () {
var c = document.createElement('div');
c.style.width = '400px';
@ -6,12 +6,12 @@ describe('PolylineGeometry', function() {
var map = new L.Map(c);
map.setView(new L.LatLng(55.8, 37.6), 6);
describe("#distanceTo", function() {
it("calculates distances to points", function() {
describe("#distanceTo", function () {
it("calculates distances to points", function () {
var p1 = map.latLngToLayerPoint(new L.LatLng(55.8, 37.6));
var p2 = map.latLngToLayerPoint(new L.LatLng(57.123076977278, 44.861962891635));
var latlngs = [[56.485503424111, 35.545556640339], [55.972522915346, 36.116845702918], [55.502459116923, 34.930322265253], [55.31534617509, 38.973291015816]]
.map(function(ll) {
.map(function (ll) {
return new L.LatLng(ll[0], ll[1]);
});
var polyline = new L.Polyline([], {

View File

@ -1,4 +1,4 @@
describe('Polyline', function() {
describe('Polyline', function () {
var c = document.createElement('div');
c.style.width = '400px';
@ -6,7 +6,7 @@ describe('Polyline', function() {
var map = new L.Map(c);
map.setView(new L.LatLng(55.8, 37.6), 6);
describe("#initialize", function() {
describe("#initialize", function () {
it("doesn't overwrite the given latlng array", function () {
var originalLatLngs = [
[1, 2],

View File

@ -29,8 +29,8 @@ describe("Map", function () {
var container = document.createElement('div'),
map = new L.Map(container);
expect(function () {
new L.Map(container);
}).to.throwException(function(e) {
L.map(container);
}).to.throwException(function (e) {
expect(e.message).to.eql("Map container is already initialized.");
});
map.remove();
@ -38,8 +38,8 @@ describe("Map", function () {
it("throws an exception if a container is not found", function () {
expect(function () {
new L.Map('nonexistentdivelement');
}).to.throwException(function(e) {
L.map('nonexistentdivelement');
}).to.throwException(function (e) {
expect(e.message).to.eql("Map container not found.");
});
map.remove();
@ -215,7 +215,7 @@ describe("Map", function () {
it("adds the layer before firing layeradd", function (done) {
var layer = { onAdd: sinon.spy(), onRemove: sinon.spy() };
map.on('layeradd', function() {
map.on('layeradd', function () {
expect(map.hasLayer(layer)).to.be.ok();
done();
});
@ -228,7 +228,7 @@ describe("Map", function () {
var spy = sinon.spy();
map.on("zoomlevelschange", spy);
expect(spy.called).not.to.be.ok();
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 10}).addTo(map);
expect(spy.called).to.be.ok();
});
});
@ -236,10 +236,10 @@ describe("Map", function () {
describe("when a new layer with greater zoomlevel coverage than the current layer is added to a map", function () {
it("fires a zoomlevelschange event", function () {
var spy = sinon.spy();
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 10}).addTo(map);
map.on("zoomlevelschange", spy);
expect(spy.called).not.to.be.ok();
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 15 }).addTo(map);
L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 15}).addTo(map);
expect(spy.called).to.be.ok();
});
});
@ -247,12 +247,12 @@ describe("Map", function () {
describe("when a new layer with the same or lower zoomlevel coverage as the current layer is added to a map", function () {
it("fires no zoomlevelschange event", function () {
var spy = sinon.spy();
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 10}).addTo(map);
map.on("zoomlevelschange", spy);
expect(spy.called).not.to.be.ok();
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 10}).addTo(map);
expect(spy.called).not.to.be.ok();
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 5 }).addTo(map);
L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 5}).addTo(map);
expect(spy.called).not.to.be.ok();
});
});
@ -311,7 +311,7 @@ describe("Map", function () {
it("removes the layer before firing layerremove", function (done) {
var layer = { onAdd: sinon.spy(), onRemove: sinon.spy() };
map.on('layerremove', function() {
map.on('layerremove', function () {
expect(map.hasLayer(layer)).not.to.be.ok();
done();
});
@ -322,9 +322,9 @@ describe("Map", function () {
describe("when the last tile layer on a map is removed", function () {
it("fires a zoomlevelschange event", function () {
map.whenReady(function(){
map.whenReady(function () {
var spy = sinon.spy();
var tl = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
var tl = L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 10}).addTo(map);
map.on("zoomlevelschange", spy);
expect(spy.called).not.to.be.ok();
@ -336,10 +336,10 @@ describe("Map", function () {
describe("when a tile layer is removed from a map and it had greater zoom level coverage than the remainding layer", function () {
it("fires a zoomlevelschange event", function () {
map.whenReady(function(){
map.whenReady(function () {
var spy = sinon.spy(),
tl = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map),
t2 = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 15 }).addTo(map);
tl = L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 10}).addTo(map),
t2 = L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 15}).addTo(map);
map.on("zoomlevelschange", spy);
expect(spy.called).to.not.be.ok();
@ -351,10 +351,10 @@ describe("Map", function () {
describe("when a tile layer is removed from a map it and it had lesser or the sa,e zoom level coverage as the remainding layer(s)", function () {
it("fires no zoomlevelschange event", function () {
map.whenReady(function(){
var tl = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map),
t2 = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map),
t3 = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 5 }).addTo(map);
map.whenReady(function () {
var tl = L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 10}).addTo(map),
t2 = L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 10}).addTo(map),
t3 = L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 5}).addTo(map);
map.on("zoomlevelschange", spy);
expect(spy).not.toHaveBeenCalled();
@ -396,11 +396,11 @@ describe("Map", function () {
describe("#invalidateSize", function () {
var container,
orig_width = 100;
origWidth = 100;
beforeEach(function () {
container = map.getContainer();
container.style.width = orig_width + "px";
container.style.width = origWidth + "px";
document.body.appendChild(container);
map.setView([0, 0], 0);
map.invalidateSize({pan: false});
@ -411,38 +411,38 @@ describe("Map", function () {
});
it("pans by the right amount when growing in 1px increments", function () {
container.style.width = (orig_width + 1) + "px";
container.style.width = (origWidth + 1) + "px";
map.invalidateSize();
expect(map._getMapPanePos().x).to.be(1);
container.style.width = (orig_width + 2) + "px";
container.style.width = (origWidth + 2) + "px";
map.invalidateSize();
expect(map._getMapPanePos().x).to.be(1);
container.style.width = (orig_width + 3) + "px";
container.style.width = (origWidth + 3) + "px";
map.invalidateSize();
expect(map._getMapPanePos().x).to.be(2);
});
it("pans by the right amount when shrinking in 1px increments", function () {
container.style.width = (orig_width - 1) + "px";
container.style.width = (origWidth - 1) + "px";
map.invalidateSize();
expect(map._getMapPanePos().x).to.be(0);
container.style.width = (orig_width - 2) + "px";
container.style.width = (origWidth - 2) + "px";
map.invalidateSize();
expect(map._getMapPanePos().x).to.be(-1);
container.style.width = (orig_width - 3) + "px";
container.style.width = (origWidth - 3) + "px";
map.invalidateSize();
expect(map._getMapPanePos().x).to.be(-1);
});
it("pans back to the original position after growing by an odd size then returning to the original size", function () {
container.style.width = (orig_width + 5) + "px";
it("pans back to the original position after growing by an odd size and back", function () {
container.style.width = (origWidth + 5) + "px";
map.invalidateSize();
container.style.width = orig_width + "px";
container.style.width = origWidth + "px";
map.invalidateSize();
expect(map._getMapPanePos().x).to.be(0);

View File

@ -1,40 +1,38 @@
describe("Map.Drag", function(){
var map;
describe("Map.Drag", function () {
describe("#addHook", function () {
it("calls the map with dragging enabled", function () {
var container = document.createElement('div'),
map = new L.Map(container,{
map = new L.Map(container, {
dragging: true
});
expect(map.dragging.enabled()).to.be(true);
map.setView([0, 0], 0);
expect(map.dragging.enabled()).to.be(true);
expect(map.dragging.enabled()).to.be(true);
map.setView([0, 0], 0);
expect(map.dragging.enabled()).to.be(true);
});
it("calls the map with dragging and worldCopyJump enabled", function () {
var container = document.createElement('div'),
map = new L.Map(container,{
map = new L.Map(container, {
dragging: true,
worldCopyJump: true
});
expect(map.dragging.enabled()).to.be(true);
map.setView([0, 0], 0);
expect(map.dragging.enabled()).to.be(true);
});
it("calls the map with dragging disabled and worldCopyJump enabled. Enables dragging after setting center and zoom", function () {
var container = document.createElement('div'),
map = new L.Map(container,{
expect(map.dragging.enabled()).to.be(true);
map.setView([0, 0], 0);
expect(map.dragging.enabled()).to.be(true);
});
it("calls the map with dragging disabled and worldCopyJump enabled; " +
"enables dragging after setting center and zoom", function () {
var container = document.createElement('div'),
map = new L.Map(container, {
dragging: false,
worldCopyJump: true
});
expect(map.dragging.enabled()).to.be(false);
map.setView([0, 0], 0);
map.dragging.enable();
expect(map.dragging.enabled()).to.be(true);
expect(map.dragging.enabled()).to.be(false);
map.setView([0, 0], 0);
map.dragging.enable();
expect(map.dragging.enabled()).to.be(true);
});
});
});