enforce indentation in specs
This commit is contained in:
parent
301473ad4d
commit
cfdbd10431
@ -4,8 +4,7 @@
|
|||||||
"quotes": 0,
|
"quotes": 0,
|
||||||
"no-shadow": 0,
|
"no-shadow": 0,
|
||||||
"no-irregular-whitespace": 0,
|
"no-irregular-whitespace": 0,
|
||||||
"no-console": 0,
|
"no-console": 0
|
||||||
"indent": 0
|
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"mocha": true
|
"mocha": true
|
||||||
|
@ -43,14 +43,14 @@ expect.Assertion.prototype.nearLatLng = function (expected, delta) {
|
|||||||
|
|
||||||
happen.at = function (what, x, y, props) {
|
happen.at = function (what, x, y, props) {
|
||||||
this.once(document.elementFromPoint(x, y), L.Util.extend({
|
this.once(document.elementFromPoint(x, y), L.Util.extend({
|
||||||
type: what,
|
type: what,
|
||||||
clientX: x,
|
clientX: x,
|
||||||
clientY: y,
|
clientY: y,
|
||||||
screenX: x,
|
screenX: x,
|
||||||
screenY: y,
|
screenY: y,
|
||||||
which: 1,
|
which: 1,
|
||||||
button: 0
|
button: 0
|
||||||
}, props || {}));
|
}, props || {}));
|
||||||
};
|
};
|
||||||
happen.drag = function (fromX, fromY, toX, toY, then, duration) {
|
happen.drag = function (fromX, fromY, toX, toY, then, duration) {
|
||||||
happen.at('mousemove', fromX, fromY);
|
happen.at('mousemove', fromX, fromY);
|
||||||
|
@ -12,8 +12,8 @@ describe("Control.Layers", function () {
|
|||||||
|
|
||||||
it("is fired on input that changes the base layer", function () {
|
it("is fired on input that changes the base layer", function () {
|
||||||
var baseLayers = {"Layer 1": L.tileLayer(''), "Layer 2": L.tileLayer('')},
|
var baseLayers = {"Layer 1": L.tileLayer(''), "Layer 2": L.tileLayer('')},
|
||||||
layers = L.control.layers(baseLayers).addTo(map),
|
layers = L.control.layers(baseLayers).addTo(map),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
|
|
||||||
map.on('baselayerchange', spy);
|
map.on('baselayerchange', spy);
|
||||||
happen.click(layers._baseLayersList.getElementsByTagName("input")[0]);
|
happen.click(layers._baseLayersList.getElementsByTagName("input")[0]);
|
||||||
@ -28,8 +28,8 @@ describe("Control.Layers", function () {
|
|||||||
|
|
||||||
it("is not fired on input that doesn't change the base layer", function () {
|
it("is not fired on input that doesn't change the base layer", function () {
|
||||||
var overlays = {"Marker 1": L.marker([0, 0]), "Marker 2": L.marker([0, 0])},
|
var overlays = {"Marker 1": L.marker([0, 0]), "Marker 2": L.marker([0, 0])},
|
||||||
layers = L.control.layers({}, overlays).addTo(map),
|
layers = L.control.layers({}, overlays).addTo(map),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
|
|
||||||
map.on('baselayerchange', spy);
|
map.on('baselayerchange', spy);
|
||||||
happen.click(layers._overlaysList.getElementsByTagName("input")[0]);
|
happen.click(layers._overlaysList.getElementsByTagName("input")[0]);
|
||||||
@ -45,8 +45,8 @@ describe("Control.Layers", function () {
|
|||||||
|
|
||||||
it("when an included layer is addded or removed", function () {
|
it("when an included layer is addded or removed", function () {
|
||||||
var baseLayer = L.tileLayer(),
|
var baseLayer = L.tileLayer(),
|
||||||
overlay = L.marker([0, 0]),
|
overlay = L.marker([0, 0]),
|
||||||
layers = L.control.layers({"Base": baseLayer}, {"Overlay": overlay}).addTo(map);
|
layers = L.control.layers({"Base": baseLayer}, {"Overlay": overlay}).addTo(map);
|
||||||
|
|
||||||
var spy = sinon.spy(layers, '_update');
|
var spy = sinon.spy(layers, '_update');
|
||||||
|
|
||||||
@ -59,8 +59,8 @@ describe("Control.Layers", function () {
|
|||||||
|
|
||||||
it("not when a non-included layer is added or removed", function () {
|
it("not when a non-included layer is added or removed", function () {
|
||||||
var baseLayer = L.tileLayer(),
|
var baseLayer = L.tileLayer(),
|
||||||
overlay = L.marker([0, 0]),
|
overlay = L.marker([0, 0]),
|
||||||
layers = L.control.layers({"Base": baseLayer}).addTo(map);
|
layers = L.control.layers({"Base": baseLayer}).addTo(map);
|
||||||
|
|
||||||
var spy = sinon.spy(layers, '_update');
|
var spy = sinon.spy(layers, '_update');
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ describe("Class", function () {
|
|||||||
|
|
||||||
describe("#extend", function () {
|
describe("#extend", function () {
|
||||||
var Klass,
|
var Klass,
|
||||||
constructor,
|
constructor,
|
||||||
method;
|
method;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
constructor = sinon.spy();
|
constructor = sinon.spy();
|
||||||
@ -131,7 +131,7 @@ describe("Class", function () {
|
|||||||
|
|
||||||
it("inherits constructor hooks", function () {
|
it("inherits constructor hooks", function () {
|
||||||
var spy1 = sinon.spy(),
|
var spy1 = sinon.spy(),
|
||||||
spy2 = sinon.spy();
|
spy2 = sinon.spy();
|
||||||
|
|
||||||
var Klass2 = Klass.extend({});
|
var Klass2 = Klass.extend({});
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ describe("Class", function () {
|
|||||||
|
|
||||||
it("does not call child constructor hooks", function () {
|
it("does not call child constructor hooks", function () {
|
||||||
var spy1 = sinon.spy(),
|
var spy1 = sinon.spy(),
|
||||||
spy2 = sinon.spy();
|
spy2 = sinon.spy();
|
||||||
|
|
||||||
var Klass2 = Klass.extend({});
|
var Klass2 = Klass.extend({});
|
||||||
|
|
||||||
|
@ -4,12 +4,12 @@ describe('Events', function () {
|
|||||||
|
|
||||||
it('fires all listeners added through #addEventListener', function () {
|
it('fires all listeners added through #addEventListener', function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy1 = sinon.spy(),
|
spy1 = sinon.spy(),
|
||||||
spy2 = sinon.spy(),
|
spy2 = sinon.spy(),
|
||||||
spy3 = sinon.spy(),
|
spy3 = sinon.spy(),
|
||||||
spy4 = sinon.spy(),
|
spy4 = sinon.spy(),
|
||||||
spy5 = sinon.spy(),
|
spy5 = sinon.spy(),
|
||||||
spy6 = sinon.spy();
|
spy6 = sinon.spy();
|
||||||
|
|
||||||
obj.addEventListener('test', spy1);
|
obj.addEventListener('test', spy1);
|
||||||
obj.addEventListener('test', spy2);
|
obj.addEventListener('test', spy2);
|
||||||
@ -37,10 +37,10 @@ describe('Events', function () {
|
|||||||
|
|
||||||
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 L.Evented(),
|
var obj = new L.Evented(),
|
||||||
obj2 = new L.Evented(),
|
obj2 = new L.Evented(),
|
||||||
obj3 = new L.Evented(),
|
obj3 = new L.Evented(),
|
||||||
obj4 = new L.Evented(),
|
obj4 = new L.Evented(),
|
||||||
foo = {};
|
foo = {};
|
||||||
|
|
||||||
function listener1(e) {
|
function listener1(e) {
|
||||||
expect(e.type).to.eql('test');
|
expect(e.type).to.eql('test');
|
||||||
@ -83,11 +83,11 @@ describe('Events', function () {
|
|||||||
|
|
||||||
it('calls no listeners removed through #removeEventListener', function () {
|
it('calls no listeners removed through #removeEventListener', function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy = sinon.spy(),
|
spy = sinon.spy(),
|
||||||
spy2 = sinon.spy(),
|
spy2 = sinon.spy(),
|
||||||
spy3 = sinon.spy(),
|
spy3 = sinon.spy(),
|
||||||
spy4 = sinon.spy(),
|
spy4 = sinon.spy(),
|
||||||
spy5 = sinon.spy();
|
spy5 = sinon.spy();
|
||||||
|
|
||||||
obj.addEventListener('test', spy);
|
obj.addEventListener('test', spy);
|
||||||
obj.removeEventListener('test', spy);
|
obj.removeEventListener('test', spy);
|
||||||
@ -130,9 +130,9 @@ describe('Events', function () {
|
|||||||
// added due to context-sensitive removeListener optimization
|
// added due to context-sensitive removeListener optimization
|
||||||
it('fires multiple listeners with the same context with id', function () {
|
it('fires multiple listeners with the same context with id', function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy1 = sinon.spy(),
|
spy1 = sinon.spy(),
|
||||||
spy2 = sinon.spy(),
|
spy2 = sinon.spy(),
|
||||||
foo = {};
|
foo = {};
|
||||||
|
|
||||||
L.Util.stamp(foo);
|
L.Util.stamp(foo);
|
||||||
|
|
||||||
@ -147,9 +147,9 @@ describe('Events', function () {
|
|||||||
|
|
||||||
it('removes listeners with stamped contexts', function () {
|
it('removes listeners with stamped contexts', function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy1 = sinon.spy(),
|
spy1 = sinon.spy(),
|
||||||
spy2 = sinon.spy(),
|
spy2 = sinon.spy(),
|
||||||
foo = {};
|
foo = {};
|
||||||
|
|
||||||
L.Util.stamp(foo);
|
L.Util.stamp(foo);
|
||||||
|
|
||||||
@ -166,9 +166,9 @@ describe('Events', function () {
|
|||||||
|
|
||||||
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 L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy1 = sinon.spy(),
|
spy1 = sinon.spy(),
|
||||||
spy2 = sinon.spy(),
|
spy2 = sinon.spy(),
|
||||||
foo = {};
|
foo = {};
|
||||||
|
|
||||||
obj.addEventListener('test', spy1, foo);
|
obj.addEventListener('test', spy1, foo);
|
||||||
L.Util.stamp(foo);
|
L.Util.stamp(foo);
|
||||||
@ -185,10 +185,10 @@ describe('Events', function () {
|
|||||||
|
|
||||||
it('removes listeners with context == this and a stamp originally added without one', function () {
|
it('removes listeners with context == this and a stamp originally added without one', function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
obj2 = new L.Evented(),
|
obj2 = new L.Evented(),
|
||||||
spy1 = sinon.spy(),
|
spy1 = sinon.spy(),
|
||||||
spy2 = sinon.spy(),
|
spy2 = sinon.spy(),
|
||||||
spy3 = sinon.spy();
|
spy3 = sinon.spy();
|
||||||
|
|
||||||
obj.addEventListener('test', spy1, obj);
|
obj.addEventListener('test', spy1, obj);
|
||||||
L.Util.stamp(obj);
|
L.Util.stamp(obj);
|
||||||
@ -265,7 +265,7 @@ describe('Events', function () {
|
|||||||
|
|
||||||
it('works like #addEventListener && #removeEventListener', function () {
|
it('works like #addEventListener && #removeEventListener', function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
|
|
||||||
obj.on('test', spy);
|
obj.on('test', spy);
|
||||||
obj.fire('test');
|
obj.fire('test');
|
||||||
@ -280,8 +280,8 @@ describe('Events', function () {
|
|||||||
|
|
||||||
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(),
|
var spy1 = sinon.spy(),
|
||||||
spy2 = sinon.spy(),
|
spy2 = sinon.spy(),
|
||||||
spy3 = sinon.spy();
|
spy3 = sinon.spy();
|
||||||
|
|
||||||
var Klass = L.Evented.extend({
|
var Klass = L.Evented.extend({
|
||||||
on: spy1,
|
on: spy1,
|
||||||
@ -305,8 +305,8 @@ describe('Events', function () {
|
|||||||
describe("#clearEventListeners", function () {
|
describe("#clearEventListeners", function () {
|
||||||
it("clears all registered listeners on an object", function () {
|
it("clears all registered listeners on an object", function () {
|
||||||
var spy = sinon.spy(),
|
var spy = sinon.spy(),
|
||||||
obj = new L.Evented(),
|
obj = new L.Evented(),
|
||||||
otherObj = new L.Evented();
|
otherObj = new L.Evented();
|
||||||
|
|
||||||
obj.on('test', spy, obj);
|
obj.on('test', spy, obj);
|
||||||
obj.on('testTwo', spy);
|
obj.on('testTwo', spy);
|
||||||
@ -322,7 +322,7 @@ describe('Events', function () {
|
|||||||
describe('#once', function () {
|
describe('#once', function () {
|
||||||
it('removes event listeners after first trigger', function () {
|
it('removes event listeners after first trigger', function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
|
|
||||||
obj.once('test', spy, obj);
|
obj.once('test', spy, obj);
|
||||||
obj.fire('test');
|
obj.fire('test');
|
||||||
@ -336,8 +336,8 @@ describe('Events', function () {
|
|||||||
|
|
||||||
it('works with an object hash', function () {
|
it('works with an object hash', function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy = sinon.spy(),
|
spy = sinon.spy(),
|
||||||
otherSpy = sinon.spy();
|
otherSpy = sinon.spy();
|
||||||
|
|
||||||
obj.once({
|
obj.once({
|
||||||
'test': spy,
|
'test': spy,
|
||||||
@ -359,7 +359,7 @@ describe('Events', function () {
|
|||||||
|
|
||||||
it("doesn't call listeners to events that have been removed", function () {
|
it("doesn't call listeners to events that have been removed", function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
|
|
||||||
obj.once('test', spy, obj);
|
obj.once('test', spy, obj);
|
||||||
obj.off('test', spy, obj);
|
obj.off('test', spy, obj);
|
||||||
@ -371,8 +371,8 @@ describe('Events', function () {
|
|||||||
|
|
||||||
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 L.Evented(),
|
var obj = new L.Evented(),
|
||||||
spy = sinon.spy(),
|
spy = sinon.spy(),
|
||||||
foo = {};
|
foo = {};
|
||||||
|
|
||||||
obj.once('test', spy, foo);
|
obj.once('test', spy, foo);
|
||||||
|
|
||||||
@ -385,10 +385,10 @@ describe('Events', function () {
|
|||||||
describe('addEventParent && removeEventParent', function () {
|
describe('addEventParent && removeEventParent', function () {
|
||||||
it('makes the object propagate events with to the given one if fired with propagate=true', function () {
|
it('makes the object propagate events with to the given one if fired with propagate=true', function () {
|
||||||
var obj = new L.Evented(),
|
var obj = new L.Evented(),
|
||||||
parent1 = new L.Evented(),
|
parent1 = new L.Evented(),
|
||||||
parent2 = new L.Evented(),
|
parent2 = new L.Evented(),
|
||||||
spy1 = sinon.spy(),
|
spy1 = sinon.spy(),
|
||||||
spy2 = sinon.spy();
|
spy2 = sinon.spy();
|
||||||
|
|
||||||
parent1.on('test', spy1);
|
parent1.on('test', spy1);
|
||||||
parent2.on('test', spy2);
|
parent2.on('test', spy2);
|
||||||
|
@ -47,10 +47,10 @@ describe('Util', function () {
|
|||||||
|
|
||||||
it('passes additional arguments to the bound function', function () {
|
it('passes additional arguments to the bound function', function () {
|
||||||
var fn = sinon.spy(),
|
var fn = sinon.spy(),
|
||||||
foo = {},
|
foo = {},
|
||||||
a = {},
|
a = {},
|
||||||
b = {},
|
b = {},
|
||||||
c = {};
|
c = {};
|
||||||
|
|
||||||
var fn2 = L.Util.bind(fn, foo, a, b);
|
var fn2 = L.Util.bind(fn, foo, a, b);
|
||||||
|
|
||||||
@ -63,13 +63,13 @@ describe('Util', function () {
|
|||||||
describe('#stamp', function () {
|
describe('#stamp', function () {
|
||||||
it('sets a unique id on the given object and returns it', function () {
|
it('sets a unique id on the given object and returns it', function () {
|
||||||
var a = {},
|
var a = {},
|
||||||
id = L.Util.stamp(a);
|
id = L.Util.stamp(a);
|
||||||
|
|
||||||
expect(typeof id).to.eql('number');
|
expect(typeof id).to.eql('number');
|
||||||
expect(L.Util.stamp(a)).to.eql(id);
|
expect(L.Util.stamp(a)).to.eql(id);
|
||||||
|
|
||||||
var b = {},
|
var b = {},
|
||||||
id2 = L.Util.stamp(b);
|
id2 = L.Util.stamp(b);
|
||||||
|
|
||||||
expect(id2).not.to.eql(id);
|
expect(id2).not.to.eql(id);
|
||||||
});
|
});
|
||||||
@ -120,7 +120,7 @@ describe('Util', function () {
|
|||||||
describe('#requestAnimFrame', function () {
|
describe('#requestAnimFrame', function () {
|
||||||
it('calles a function on next frame, unless canceled', function (done) {
|
it('calles a function on next frame, unless canceled', function (done) {
|
||||||
var spy = sinon.spy(),
|
var spy = sinon.spy(),
|
||||||
foo = {};
|
foo = {};
|
||||||
|
|
||||||
L.Util.requestAnimFrame(spy);
|
L.Util.requestAnimFrame(spy);
|
||||||
|
|
||||||
@ -179,21 +179,21 @@ describe('Util', function () {
|
|||||||
|
|
||||||
it('creates a distinct options object', function () {
|
it('creates a distinct options object', function () {
|
||||||
var opts = {},
|
var opts = {},
|
||||||
o = L.Util.create({options: opts});
|
o = L.Util.create({options: opts});
|
||||||
L.Util.setOptions(o, {});
|
L.Util.setOptions(o, {});
|
||||||
expect(o.options).not.to.equal(opts);
|
expect(o.options).not.to.equal(opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doesn't create a distinct options object if object already has own options", function () {
|
it("doesn't create a distinct options object if object already has own options", function () {
|
||||||
var opts = {},
|
var opts = {},
|
||||||
o = {options: opts};
|
o = {options: opts};
|
||||||
L.Util.setOptions(o, {});
|
L.Util.setOptions(o, {});
|
||||||
expect(o.options).to.equal(opts);
|
expect(o.options).to.equal(opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inherits options prototypally', function () {
|
it('inherits options prototypally', function () {
|
||||||
var opts = {},
|
var opts = {},
|
||||||
o = L.Util.create({options: opts});
|
o = L.Util.create({options: opts});
|
||||||
L.Util.setOptions(o, {});
|
L.Util.setOptions(o, {});
|
||||||
opts.foo = 'bar';
|
opts.foo = 'bar';
|
||||||
expect(o.options.foo).to.eql('bar');
|
expect(o.options.foo).to.eql('bar');
|
||||||
|
@ -26,7 +26,7 @@ describe('DomEvent', function () {
|
|||||||
describe('#addListener', function () {
|
describe('#addListener', function () {
|
||||||
it('adds a listener and calls it on event', function () {
|
it('adds a listener and calls it on event', function () {
|
||||||
var listener1 = sinon.spy(),
|
var listener1 = sinon.spy(),
|
||||||
listener2 = sinon.spy();
|
listener2 = sinon.spy();
|
||||||
|
|
||||||
L.DomEvent.addListener(el, 'click', listener1);
|
L.DomEvent.addListener(el, 'click', listener1);
|
||||||
L.DomEvent.addListener(el, 'click', listener2);
|
L.DomEvent.addListener(el, 'click', listener2);
|
||||||
@ -39,7 +39,7 @@ describe('DomEvent', function () {
|
|||||||
|
|
||||||
it('binds "this" to the given context', function () {
|
it('binds "this" to the given context', function () {
|
||||||
var obj = {foo: 'bar'},
|
var obj = {foo: 'bar'},
|
||||||
result;
|
result;
|
||||||
|
|
||||||
L.DomEvent.addListener(el, 'click', function () {
|
L.DomEvent.addListener(el, 'click', function () {
|
||||||
result = this;
|
result = this;
|
||||||
@ -78,7 +78,7 @@ describe('DomEvent', function () {
|
|||||||
describe('#stopPropagation', function () {
|
describe('#stopPropagation', function () {
|
||||||
it('stops propagation of the given event', function () {
|
it('stops propagation of the given event', function () {
|
||||||
var child = document.createElement('div'),
|
var child = document.createElement('div'),
|
||||||
listener = sinon.spy();
|
listener = sinon.spy();
|
||||||
|
|
||||||
el.appendChild(child);
|
el.appendChild(child);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ describe("Point", function () {
|
|||||||
describe('#subtract', function () {
|
describe('#subtract', function () {
|
||||||
it('subtracts the given point from this one', function () {
|
it('subtracts the given point from this one', function () {
|
||||||
var a = new L.Point(50, 30),
|
var a = new L.Point(50, 30),
|
||||||
b = new L.Point(20, 10);
|
b = new L.Point(20, 10);
|
||||||
expect(a.subtract(b)).to.eql(new L.Point(30, 20));
|
expect(a.subtract(b)).to.eql(new L.Point(30, 20));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -69,9 +69,9 @@ describe("Point", function () {
|
|||||||
describe('#contains', function () {
|
describe('#contains', function () {
|
||||||
it('returns true if the point is bigger in absolute dimensions than the passed one', function () {
|
it('returns true if the point is bigger in absolute dimensions than the passed one', function () {
|
||||||
var p1 = new L.Point(50, 30),
|
var p1 = new L.Point(50, 30),
|
||||||
p2 = new L.Point(-40, 20),
|
p2 = new L.Point(-40, 20),
|
||||||
p3 = new L.Point(60, -20),
|
p3 = new L.Point(60, -20),
|
||||||
p4 = new L.Point(-40, -40);
|
p4 = new L.Point(-40, -40);
|
||||||
|
|
||||||
expect(p1.contains(p2)).to.be(true);
|
expect(p1.contains(p2)).to.be(true);
|
||||||
expect(p1.contains(p3)).to.be(false);
|
expect(p1.contains(p3)).to.be(false);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
fg2.addLayer(marker);
|
fg2.addLayer(marker);
|
||||||
|
|
||||||
var wasClicked1,
|
var wasClicked1,
|
||||||
wasClicked2;
|
wasClicked2;
|
||||||
|
|
||||||
fg2.on('click', function (e) {
|
fg2.on('click', function (e) {
|
||||||
expect(e.layer).to.be(marker);
|
expect(e.layer).to.be(marker);
|
||||||
|
@ -247,8 +247,8 @@ describe("L.LayerGroup#toGeoJSON", function () {
|
|||||||
|
|
||||||
it("returns a 3D FeatureCollection object", function () {
|
it("returns a 3D FeatureCollection object", function () {
|
||||||
var marker = new L.Marker([10, 20, 30]),
|
var marker = new L.Marker([10, 20, 30]),
|
||||||
polyline = new L.Polyline([[10, 20, 30], [2, 5, 10]]),
|
polyline = new L.Polyline([[10, 20, 30], [2, 5, 10]]),
|
||||||
layerGroup = new L.LayerGroup([marker, polyline]);
|
layerGroup = new L.LayerGroup([marker, polyline]);
|
||||||
expect(layerGroup.toGeoJSON()).to.eql({
|
expect(layerGroup.toGeoJSON()).to.eql({
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
features: [marker.toGeoJSON(), polyline.toGeoJSON()]
|
features: [marker.toGeoJSON(), polyline.toGeoJSON()]
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
describe("#addLayer", function () {
|
describe("#addLayer", function () {
|
||||||
it('adds a layer', function () {
|
it('adds a layer', function () {
|
||||||
var lg = L.layerGroup(),
|
var lg = L.layerGroup(),
|
||||||
marker = L.marker([0, 0]);
|
marker = L.marker([0, 0]);
|
||||||
|
|
||||||
expect(lg.addLayer(marker)).to.eql(lg);
|
expect(lg.addLayer(marker)).to.eql(lg);
|
||||||
|
|
||||||
@ -22,7 +22,7 @@
|
|||||||
describe("#removeLayer", function () {
|
describe("#removeLayer", function () {
|
||||||
it('removes a layer', function () {
|
it('removes a layer', function () {
|
||||||
var lg = L.layerGroup(),
|
var lg = L.layerGroup(),
|
||||||
marker = L.marker([0, 0]);
|
marker = L.marker([0, 0]);
|
||||||
|
|
||||||
lg.addLayer(marker);
|
lg.addLayer(marker);
|
||||||
expect(lg.removeLayer(marker)).to.eql(lg);
|
expect(lg.removeLayer(marker)).to.eql(lg);
|
||||||
@ -34,7 +34,7 @@
|
|||||||
describe("#clearLayers", function () {
|
describe("#clearLayers", function () {
|
||||||
it('removes all layers', function () {
|
it('removes all layers', function () {
|
||||||
var lg = L.layerGroup(),
|
var lg = L.layerGroup(),
|
||||||
marker = L.marker([0, 0]);
|
marker = L.marker([0, 0]);
|
||||||
|
|
||||||
lg.addLayer(marker);
|
lg.addLayer(marker);
|
||||||
expect(lg.clearLayers()).to.eql(lg);
|
expect(lg.clearLayers()).to.eql(lg);
|
||||||
@ -46,7 +46,7 @@
|
|||||||
describe("#getLayers", function () {
|
describe("#getLayers", function () {
|
||||||
it('gets all layers', function () {
|
it('gets all layers', function () {
|
||||||
var lg = L.layerGroup(),
|
var lg = L.layerGroup(),
|
||||||
marker = L.marker([0, 0]);
|
marker = L.marker([0, 0]);
|
||||||
|
|
||||||
lg.addLayer(marker);
|
lg.addLayer(marker);
|
||||||
|
|
||||||
@ -57,8 +57,8 @@
|
|||||||
describe("#eachLayer", function () {
|
describe("#eachLayer", function () {
|
||||||
it('iterates over all layers', function () {
|
it('iterates over all layers', function () {
|
||||||
var lg = L.layerGroup(),
|
var lg = L.layerGroup(),
|
||||||
marker = L.marker([0, 0]),
|
marker = L.marker([0, 0]),
|
||||||
ctx = {foo: 'bar'};
|
ctx = {foo: 'bar'};
|
||||||
|
|
||||||
lg.addLayer(marker);
|
lg.addLayer(marker);
|
||||||
|
|
||||||
|
@ -200,10 +200,11 @@ describe('Popup', function () {
|
|||||||
L.Icon.Default.prototype.options.popupAnchor = [0, 0];
|
L.Icon.Default.prototype.options.popupAnchor = [0, 0];
|
||||||
|
|
||||||
var latlng = new L.LatLng(55.8, 37.6),
|
var latlng = new L.LatLng(55.8, 37.6),
|
||||||
offset = new L.Point(20, 30),
|
offset = new L.Point(20, 30),
|
||||||
icon = new L.DivIcon({popupAnchor: offset}),
|
icon = new L.DivIcon({popupAnchor: offset}),
|
||||||
marker1 = new L.Marker(latlng),
|
marker1 = new L.Marker(latlng),
|
||||||
marker2 = new L.Marker(latlng, {icon: icon});
|
marker2 = new L.Marker(latlng, {icon: icon});
|
||||||
|
|
||||||
marker1.bindPopup('Popup').addTo(map);
|
marker1.bindPopup('Popup').addTo(map);
|
||||||
marker1.openPopup();
|
marker1.openPopup();
|
||||||
var defaultLeft = parseInt(marker1._popup._container.style.left, 10);
|
var defaultLeft = parseInt(marker1._popup._container.style.left, 10);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
describe("Marker", function () {
|
describe("Marker", function () {
|
||||||
var map,
|
var map,
|
||||||
spy,
|
spy,
|
||||||
div,
|
div,
|
||||||
icon1,
|
icon1,
|
||||||
icon2;
|
icon2;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
div = document.createElement('div');
|
div = document.createElement('div');
|
||||||
|
@ -51,7 +51,7 @@ describe('GridLayer', function () {
|
|||||||
|
|
||||||
for (var i = 0; i < tiles.length; i++) {
|
for (var i = 0; i < tiles.length; i++) {
|
||||||
var coords = tiles[i].coords,
|
var coords = tiles[i].coords,
|
||||||
pos = L.DomUtil.getPosition(tiles[i].tile);
|
pos = L.DomUtil.getPosition(tiles[i].tile);
|
||||||
|
|
||||||
loaded[pos.x + ':' + pos.y] = [coords.x, coords.y];
|
loaded[pos.x + ':' + pos.y] = [coords.x, coords.y];
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ describe('GridLayer', function () {
|
|||||||
var layer = L.gridLayer().addTo(map);
|
var layer = L.gridLayer().addTo(map);
|
||||||
|
|
||||||
var onAdd = layer.onAdd,
|
var onAdd = layer.onAdd,
|
||||||
onAddSpy = sinon.spy();
|
onAddSpy = sinon.spy();
|
||||||
layer.onAdd = function () {
|
layer.onAdd = function () {
|
||||||
onAdd.apply(this, arguments);
|
onAdd.apply(this, arguments);
|
||||||
onAddSpy();
|
onAddSpy();
|
||||||
@ -129,7 +129,7 @@ describe('GridLayer', function () {
|
|||||||
describe("when a tilelayer is added to a map with no other layers", function () {
|
describe("when a tilelayer is added to a map with no other layers", function () {
|
||||||
it("has the same zoomlevels as the tilelayer", function () {
|
it("has the same zoomlevels as the tilelayer", function () {
|
||||||
var maxZoom = 10,
|
var maxZoom = 10,
|
||||||
minZoom = 5;
|
minZoom = 5;
|
||||||
|
|
||||||
map.setView([0, 0], 1);
|
map.setView([0, 0], 1);
|
||||||
|
|
||||||
|
@ -37,11 +37,8 @@ describe('Polygon', function () {
|
|||||||
|
|
||||||
it("can be initialized with holes", function () {
|
it("can be initialized with holes", function () {
|
||||||
var originalLatLngs = [
|
var originalLatLngs = [
|
||||||
[ //external ring
|
[[0, 10], [10, 10], [10, 0]], // external ring
|
||||||
[0, 10], [10, 10], [10, 0]
|
[[2, 3], [2, 4], [3, 4]] // hole
|
||||||
], [ //hole
|
|
||||||
[2, 3], [2, 4], [3, 4]
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
var polygon = new L.Polygon(originalLatLngs);
|
var polygon = new L.Polygon(originalLatLngs);
|
||||||
@ -116,11 +113,8 @@ describe('Polygon', function () {
|
|||||||
|
|
||||||
it("can be set external ring and holes", function () {
|
it("can be set external ring and holes", function () {
|
||||||
var latLngs = [
|
var latLngs = [
|
||||||
[ //external ring
|
[[0, 10], [10, 10], [10, 0]], // external ring
|
||||||
[0, 10], [10, 10], [10, 0]
|
[[2, 3], [2, 4], [3, 4]] // hole
|
||||||
], [ //hole
|
|
||||||
[2, 3], [2, 4], [3, 4]
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
var polygon = new L.Polygon([]);
|
var polygon = new L.Polygon([]);
|
||||||
@ -207,10 +201,8 @@ describe('Polygon', function () {
|
|||||||
|
|
||||||
it("should return first latlngs on a multipolygon with hole", function () {
|
it("should return first latlngs on a multipolygon with hole", function () {
|
||||||
var latlngs = [
|
var latlngs = [
|
||||||
[
|
[[L.latLng([0, 10]), L.latLng([10, 10]), L.latLng([10, 0])],
|
||||||
[L.latLng([0, 10]), L.latLng([10, 10]), L.latLng([10, 0])],
|
[L.latLng([2, 3]), L.latLng([2, 4]), L.latLng([3, 4])]],
|
||||||
[L.latLng([2, 3]), L.latLng([2, 4]), L.latLng([3, 4])]
|
|
||||||
],
|
|
||||||
[[L.latLng([10, 20]), L.latLng([30, 40]), L.latLng([50, 60])]]
|
[[L.latLng([10, 20]), L.latLng([30, 40]), L.latLng([50, 60])]]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
describe("Map", function () {
|
describe("Map", function () {
|
||||||
var map,
|
var map,
|
||||||
spy;
|
spy;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
map = L.map(document.createElement('div'));
|
map = L.map(document.createElement('div'));
|
||||||
});
|
});
|
||||||
@ -9,7 +9,7 @@ describe("Map", function () {
|
|||||||
it("fires an unload event if loaded", function () {
|
it("fires an unload event if loaded", function () {
|
||||||
var container = document.createElement('div'),
|
var container = document.createElement('div'),
|
||||||
map = new L.Map(container).setView([0, 0], 0),
|
map = new L.Map(container).setView([0, 0], 0),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
map.on('unload', spy);
|
map.on('unload', spy);
|
||||||
map.remove();
|
map.remove();
|
||||||
expect(spy.called).to.be.ok();
|
expect(spy.called).to.be.ok();
|
||||||
@ -18,7 +18,7 @@ describe("Map", function () {
|
|||||||
it("fires no unload event if not loaded", function () {
|
it("fires no unload event if not loaded", function () {
|
||||||
var container = document.createElement('div'),
|
var container = document.createElement('div'),
|
||||||
map = new L.Map(container),
|
map = new L.Map(container),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
map.on('unload', spy);
|
map.on('unload', spy);
|
||||||
map.remove();
|
map.remove();
|
||||||
expect(spy.called).not.to.be.ok();
|
expect(spy.called).not.to.be.ok();
|
||||||
@ -27,7 +27,7 @@ describe("Map", function () {
|
|||||||
describe("corner case checking", function () {
|
describe("corner case checking", function () {
|
||||||
it("throws an exception upon reinitialization", function () {
|
it("throws an exception upon reinitialization", function () {
|
||||||
var container = document.createElement('div'),
|
var container = document.createElement('div'),
|
||||||
map = new L.Map(container);
|
map = new L.Map(container);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
L.map(container);
|
L.map(container);
|
||||||
}).to.throwException(function (e) {
|
}).to.throwException(function (e) {
|
||||||
@ -56,7 +56,7 @@ describe("Map", function () {
|
|||||||
it("unbinds events", function () {
|
it("unbinds events", function () {
|
||||||
var container = document.createElement('div'),
|
var container = document.createElement('div'),
|
||||||
map = new L.Map(container).setView([0, 0], 1),
|
map = new L.Map(container).setView([0, 0], 1),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
|
|
||||||
map.on('click dblclick mousedown mouseup mousemove', spy);
|
map.on('click dblclick mousedown mouseup mousemove', spy);
|
||||||
map.remove();
|
map.remove();
|
||||||
@ -443,7 +443,7 @@ describe("Map", function () {
|
|||||||
it("fires a zoomlevelschange event", function () {
|
it("fires a zoomlevelschange event", function () {
|
||||||
map.whenReady(function () {
|
map.whenReady(function () {
|
||||||
var spy = sinon.spy(),
|
var spy = sinon.spy(),
|
||||||
tl = L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 10}).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);
|
t2 = L.tileLayer("{z}{x}{y}", {minZoom: 0, maxZoom: 15}).addTo(map);
|
||||||
|
|
||||||
map.on("zoomlevelschange", spy);
|
map.on("zoomlevelschange", spy);
|
||||||
@ -480,7 +480,7 @@ describe("Map", function () {
|
|||||||
it("calls the provided function for each layer", function () {
|
it("calls the provided function for each layer", function () {
|
||||||
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
|
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
|
||||||
t2 = L.tileLayer("{z}{x}{y}").addTo(map),
|
t2 = L.tileLayer("{z}{x}{y}").addTo(map),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
|
|
||||||
map.eachLayer(spy);
|
map.eachLayer(spy);
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ describe("Map", function () {
|
|||||||
|
|
||||||
it("calls the provided function with the provided context", function () {
|
it("calls the provided function with the provided context", function () {
|
||||||
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
|
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
|
||||||
spy = sinon.spy();
|
spy = sinon.spy();
|
||||||
|
|
||||||
map.eachLayer(spy, map);
|
map.eachLayer(spy, map);
|
||||||
|
|
||||||
@ -502,7 +502,7 @@ describe("Map", function () {
|
|||||||
describe("#invalidateSize", function () {
|
describe("#invalidateSize", function () {
|
||||||
var container,
|
var container,
|
||||||
origWidth = 100,
|
origWidth = 100,
|
||||||
clock;
|
clock;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
container = map.getContainer();
|
container = map.getContainer();
|
||||||
@ -604,15 +604,15 @@ describe("Map", function () {
|
|||||||
|
|
||||||
it('move to requested center and zoom, and call zoomend once', function (done) {
|
it('move to requested center and zoom, and call zoomend once', function (done) {
|
||||||
var spy = sinon.spy(),
|
var spy = sinon.spy(),
|
||||||
newCenter = new L.LatLng(10, 11),
|
newCenter = new L.LatLng(10, 11),
|
||||||
newZoom = 12,
|
newZoom = 12;
|
||||||
callback = function () {
|
var callback = function () {
|
||||||
expect(map.getCenter()).to.eql(newCenter);
|
expect(map.getCenter()).to.eql(newCenter);
|
||||||
expect(map.getZoom()).to.eql(newZoom);
|
expect(map.getZoom()).to.eql(newZoom);
|
||||||
spy();
|
spy();
|
||||||
expect(spy.calledOnce).to.be.ok();
|
expect(spy.calledOnce).to.be.ok();
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
map.setView([0, 0], 0);
|
map.setView([0, 0], 0);
|
||||||
map.once('zoomend', callback).flyTo(newCenter, newZoom);
|
map.once('zoomend', callback).flyTo(newCenter, newZoom);
|
||||||
});
|
});
|
||||||
@ -695,8 +695,8 @@ describe("Map", function () {
|
|||||||
|
|
||||||
it("mouseout is only forwared if fired on the original target", function () {
|
it("mouseout is only forwared if fired on the original target", function () {
|
||||||
var mapSpy = sinon.spy(),
|
var mapSpy = sinon.spy(),
|
||||||
layerSpy = sinon.spy(),
|
layerSpy = sinon.spy(),
|
||||||
otherSpy = sinon.spy();
|
otherSpy = sinon.spy();
|
||||||
var layer = new L.Polygon([[1, 2], [3, 4], [5, 6]]).addTo(map);
|
var layer = new L.Polygon([[1, 2], [3, 4], [5, 6]]).addTo(map);
|
||||||
var other = new L.Polygon([[10, 20], [30, 40], [50, 60]]).addTo(map);
|
var other = new L.Polygon([[10, 20], [30, 40], [50, 60]]).addTo(map);
|
||||||
map.on("mouseout", mapSpy);
|
map.on("mouseout", mapSpy);
|
||||||
@ -710,8 +710,8 @@ describe("Map", function () {
|
|||||||
|
|
||||||
it("mouseout is not forwared to layers if fired on the map", function () {
|
it("mouseout is not forwared to layers if fired on the map", function () {
|
||||||
var mapSpy = sinon.spy(),
|
var mapSpy = sinon.spy(),
|
||||||
layerSpy = sinon.spy(),
|
layerSpy = sinon.spy(),
|
||||||
otherSpy = sinon.spy();
|
otherSpy = sinon.spy();
|
||||||
var layer = new L.Polygon([[1, 2], [3, 4], [5, 6]]).addTo(map);
|
var layer = new L.Polygon([[1, 2], [3, 4], [5, 6]]).addTo(map);
|
||||||
var other = new L.Polygon([[10, 20], [30, 40], [50, 60]]).addTo(map);
|
var other = new L.Polygon([[10, 20], [30, 40], [50, 60]]).addTo(map);
|
||||||
map.on("mouseout", mapSpy);
|
map.on("mouseout", mapSpy);
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
describe("Map.Drag", function () {
|
describe("Map.Drag", function () {
|
||||||
describe("#addHook", function () {
|
describe("#addHook", function () {
|
||||||
it("calls the map with dragging enabled", function () {
|
it("calls the map with dragging enabled", function () {
|
||||||
var container = document.createElement('div'),
|
var container = document.createElement('div');
|
||||||
map = new L.Map(container, {
|
var map = new L.Map(container, {
|
||||||
dragging: true
|
dragging: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(map.dragging.enabled()).to.be(true);
|
expect(map.dragging.enabled()).to.be(true);
|
||||||
map.setView([0, 0], 0);
|
map.setView([0, 0], 0);
|
||||||
expect(map.dragging.enabled()).to.be(true);
|
expect(map.dragging.enabled()).to.be(true);
|
||||||
});
|
});
|
||||||
it("calls the map with dragging and worldCopyJump enabled", function () {
|
it("calls the map with dragging and worldCopyJump enabled", function () {
|
||||||
var container = document.createElement('div'),
|
var container = document.createElement('div');
|
||||||
map = new L.Map(container, {
|
var map = new L.Map(container, {
|
||||||
dragging: true,
|
dragging: true,
|
||||||
worldCopyJump: true
|
worldCopyJump: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(map.dragging.enabled()).to.be(true);
|
expect(map.dragging.enabled()).to.be(true);
|
||||||
map.setView([0, 0], 0);
|
map.setView([0, 0], 0);
|
||||||
expect(map.dragging.enabled()).to.be(true);
|
expect(map.dragging.enabled()).to.be(true);
|
||||||
});
|
});
|
||||||
it("calls the map with dragging disabled and worldCopyJump enabled; " +
|
it("calls the map with dragging disabled and worldCopyJump enabled; " +
|
||||||
"enables dragging after setting center and zoom", function () {
|
"enables dragging after setting center and zoom", function () {
|
||||||
var container = document.createElement('div'),
|
var container = document.createElement('div');
|
||||||
map = new L.Map(container, {
|
var map = new L.Map(container, {
|
||||||
dragging: false,
|
dragging: false,
|
||||||
worldCopyJump: true
|
worldCopyJump: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(map.dragging.enabled()).to.be(false);
|
expect(map.dragging.enabled()).to.be(false);
|
||||||
map.setView([0, 0], 0);
|
map.setView([0, 0], 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user