enforce indentation in specs

This commit is contained in:
Vladimir Agafonkin 2015-09-25 13:55:37 +03:00
parent 301473ad4d
commit cfdbd10431
17 changed files with 145 additions and 153 deletions

View File

@ -4,8 +4,7 @@
"quotes": 0,
"no-shadow": 0,
"no-irregular-whitespace": 0,
"no-console": 0,
"indent": 0
"no-console": 0
},
"env": {
"mocha": true

View File

@ -43,14 +43,14 @@ expect.Assertion.prototype.nearLatLng = function (expected, delta) {
happen.at = function (what, x, y, props) {
this.once(document.elementFromPoint(x, y), L.Util.extend({
type: what,
clientX: x,
clientY: y,
screenX: x,
screenY: y,
which: 1,
button: 0
}, props || {}));
type: what,
clientX: x,
clientY: y,
screenX: x,
screenY: y,
which: 1,
button: 0
}, props || {}));
};
happen.drag = function (fromX, fromY, toX, toY, then, duration) {
happen.at('mousemove', fromX, fromY);

View File

@ -12,8 +12,8 @@ describe("Control.Layers", function () {
it("is fired on input that changes the base layer", function () {
var baseLayers = {"Layer 1": L.tileLayer(''), "Layer 2": L.tileLayer('')},
layers = L.control.layers(baseLayers).addTo(map),
spy = sinon.spy();
layers = L.control.layers(baseLayers).addTo(map),
spy = sinon.spy();
map.on('baselayerchange', spy);
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 () {
var overlays = {"Marker 1": L.marker([0, 0]), "Marker 2": L.marker([0, 0])},
layers = L.control.layers({}, overlays).addTo(map),
spy = sinon.spy();
layers = L.control.layers({}, overlays).addTo(map),
spy = sinon.spy();
map.on('baselayerchange', spy);
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 () {
var baseLayer = L.tileLayer(),
overlay = L.marker([0, 0]),
layers = L.control.layers({"Base": baseLayer}, {"Overlay": overlay}).addTo(map);
overlay = L.marker([0, 0]),
layers = L.control.layers({"Base": baseLayer}, {"Overlay": overlay}).addTo(map);
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 () {
var baseLayer = L.tileLayer(),
overlay = L.marker([0, 0]),
layers = L.control.layers({"Base": baseLayer}).addTo(map);
overlay = L.marker([0, 0]),
layers = L.control.layers({"Base": baseLayer}).addTo(map);
var spy = sinon.spy(layers, '_update');

View File

@ -2,8 +2,8 @@ describe("Class", function () {
describe("#extend", function () {
var Klass,
constructor,
method;
constructor,
method;
beforeEach(function () {
constructor = sinon.spy();
@ -131,7 +131,7 @@ describe("Class", function () {
it("inherits constructor hooks", function () {
var spy1 = sinon.spy(),
spy2 = sinon.spy();
spy2 = sinon.spy();
var Klass2 = Klass.extend({});
@ -146,7 +146,7 @@ describe("Class", function () {
it("does not call child constructor hooks", function () {
var spy1 = sinon.spy(),
spy2 = sinon.spy();
spy2 = sinon.spy();
var Klass2 = Klass.extend({});

View File

@ -4,12 +4,12 @@ describe('Events', function () {
it('fires all listeners added through #addEventListener', function () {
var obj = new L.Evented(),
spy1 = sinon.spy(),
spy2 = sinon.spy(),
spy3 = sinon.spy(),
spy4 = sinon.spy(),
spy5 = sinon.spy(),
spy6 = sinon.spy();
spy1 = sinon.spy(),
spy2 = sinon.spy(),
spy3 = sinon.spy(),
spy4 = sinon.spy(),
spy5 = sinon.spy(),
spy6 = sinon.spy();
obj.addEventListener('test', spy1);
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 () {
var obj = new L.Evented(),
obj2 = new L.Evented(),
obj3 = new L.Evented(),
obj4 = new L.Evented(),
foo = {};
obj2 = new L.Evented(),
obj3 = new L.Evented(),
obj4 = new L.Evented(),
foo = {};
function listener1(e) {
expect(e.type).to.eql('test');
@ -83,11 +83,11 @@ describe('Events', function () {
it('calls no listeners removed through #removeEventListener', function () {
var obj = new L.Evented(),
spy = sinon.spy(),
spy2 = sinon.spy(),
spy3 = sinon.spy(),
spy4 = sinon.spy(),
spy5 = sinon.spy();
spy = sinon.spy(),
spy2 = sinon.spy(),
spy3 = sinon.spy(),
spy4 = sinon.spy(),
spy5 = sinon.spy();
obj.addEventListener('test', spy);
obj.removeEventListener('test', spy);
@ -130,9 +130,9 @@ describe('Events', function () {
// added due to context-sensitive removeListener optimization
it('fires multiple listeners with the same context with id', function () {
var obj = new L.Evented(),
spy1 = sinon.spy(),
spy2 = sinon.spy(),
foo = {};
spy1 = sinon.spy(),
spy2 = sinon.spy(),
foo = {};
L.Util.stamp(foo);
@ -147,9 +147,9 @@ describe('Events', function () {
it('removes listeners with stamped contexts', function () {
var obj = new L.Evented(),
spy1 = sinon.spy(),
spy2 = sinon.spy(),
foo = {};
spy1 = sinon.spy(),
spy2 = sinon.spy(),
foo = {};
L.Util.stamp(foo);
@ -166,9 +166,9 @@ describe('Events', function () {
it('removes listeners with a stamp originally added without one', function () {
var obj = new L.Evented(),
spy1 = sinon.spy(),
spy2 = sinon.spy(),
foo = {};
spy1 = sinon.spy(),
spy2 = sinon.spy(),
foo = {};
obj.addEventListener('test', spy1, 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 () {
var obj = new L.Evented(),
obj2 = new L.Evented(),
spy1 = sinon.spy(),
spy2 = sinon.spy(),
spy3 = sinon.spy();
obj2 = new L.Evented(),
spy1 = sinon.spy(),
spy2 = sinon.spy(),
spy3 = sinon.spy();
obj.addEventListener('test', spy1, obj);
L.Util.stamp(obj);
@ -265,7 +265,7 @@ describe('Events', function () {
it('works like #addEventListener && #removeEventListener', function () {
var obj = new L.Evented(),
spy = sinon.spy();
spy = sinon.spy();
obj.on('test', spy);
obj.fire('test');
@ -280,8 +280,8 @@ describe('Events', function () {
it('does not override existing methods with the same name', function () {
var spy1 = sinon.spy(),
spy2 = sinon.spy(),
spy3 = sinon.spy();
spy2 = sinon.spy(),
spy3 = sinon.spy();
var Klass = L.Evented.extend({
on: spy1,
@ -305,8 +305,8 @@ describe('Events', function () {
describe("#clearEventListeners", function () {
it("clears all registered listeners on an object", function () {
var spy = sinon.spy(),
obj = new L.Evented(),
otherObj = new L.Evented();
obj = new L.Evented(),
otherObj = new L.Evented();
obj.on('test', spy, obj);
obj.on('testTwo', spy);
@ -322,7 +322,7 @@ describe('Events', function () {
describe('#once', function () {
it('removes event listeners after first trigger', function () {
var obj = new L.Evented(),
spy = sinon.spy();
spy = sinon.spy();
obj.once('test', spy, obj);
obj.fire('test');
@ -336,8 +336,8 @@ describe('Events', function () {
it('works with an object hash', function () {
var obj = new L.Evented(),
spy = sinon.spy(),
otherSpy = sinon.spy();
spy = sinon.spy(),
otherSpy = sinon.spy();
obj.once({
'test': spy,
@ -359,7 +359,7 @@ describe('Events', function () {
it("doesn't call listeners to events that have been removed", function () {
var obj = new L.Evented(),
spy = sinon.spy();
spy = sinon.spy();
obj.once('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 () {
var obj = new L.Evented(),
spy = sinon.spy(),
foo = {};
spy = sinon.spy(),
foo = {};
obj.once('test', spy, foo);
@ -385,10 +385,10 @@ describe('Events', function () {
describe('addEventParent && removeEventParent', function () {
it('makes the object propagate events with to the given one if fired with propagate=true', function () {
var obj = new L.Evented(),
parent1 = new L.Evented(),
parent2 = new L.Evented(),
spy1 = sinon.spy(),
spy2 = sinon.spy();
parent1 = new L.Evented(),
parent2 = new L.Evented(),
spy1 = sinon.spy(),
spy2 = sinon.spy();
parent1.on('test', spy1);
parent2.on('test', spy2);

View File

@ -47,10 +47,10 @@ describe('Util', function () {
it('passes additional arguments to the bound function', function () {
var fn = sinon.spy(),
foo = {},
a = {},
b = {},
c = {};
foo = {},
a = {},
b = {},
c = {};
var fn2 = L.Util.bind(fn, foo, a, b);
@ -63,13 +63,13 @@ describe('Util', function () {
describe('#stamp', function () {
it('sets a unique id on the given object and returns it', function () {
var a = {},
id = L.Util.stamp(a);
id = L.Util.stamp(a);
expect(typeof id).to.eql('number');
expect(L.Util.stamp(a)).to.eql(id);
var b = {},
id2 = L.Util.stamp(b);
id2 = L.Util.stamp(b);
expect(id2).not.to.eql(id);
});
@ -120,7 +120,7 @@ describe('Util', function () {
describe('#requestAnimFrame', function () {
it('calles a function on next frame, unless canceled', function (done) {
var spy = sinon.spy(),
foo = {};
foo = {};
L.Util.requestAnimFrame(spy);
@ -179,21 +179,21 @@ describe('Util', function () {
it('creates a distinct options object', function () {
var opts = {},
o = L.Util.create({options: opts});
o = L.Util.create({options: opts});
L.Util.setOptions(o, {});
expect(o.options).not.to.equal(opts);
});
it("doesn't create a distinct options object if object already has own options", function () {
var opts = {},
o = {options: opts};
o = {options: opts};
L.Util.setOptions(o, {});
expect(o.options).to.equal(opts);
});
it('inherits options prototypally', function () {
var opts = {},
o = L.Util.create({options: opts});
o = L.Util.create({options: opts});
L.Util.setOptions(o, {});
opts.foo = 'bar';
expect(o.options.foo).to.eql('bar');

View File

@ -26,7 +26,7 @@ describe('DomEvent', function () {
describe('#addListener', function () {
it('adds a listener and calls it on event', function () {
var listener1 = sinon.spy(),
listener2 = sinon.spy();
listener2 = sinon.spy();
L.DomEvent.addListener(el, 'click', listener1);
L.DomEvent.addListener(el, 'click', listener2);
@ -39,7 +39,7 @@ describe('DomEvent', function () {
it('binds "this" to the given context', function () {
var obj = {foo: 'bar'},
result;
result;
L.DomEvent.addListener(el, 'click', function () {
result = this;
@ -78,7 +78,7 @@ describe('DomEvent', function () {
describe('#stopPropagation', function () {
it('stops propagation of the given event', function () {
var child = document.createElement('div'),
listener = sinon.spy();
listener = sinon.spy();
el.appendChild(child);

View File

@ -18,7 +18,7 @@ describe("Point", 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);
b = new L.Point(20, 10);
expect(a.subtract(b)).to.eql(new L.Point(30, 20));
});
});
@ -69,9 +69,9 @@ describe("Point", function () {
describe('#contains', function () {
it('returns true if the point is bigger in absolute dimensions than the passed one', function () {
var p1 = new L.Point(50, 30),
p2 = new L.Point(-40, 20),
p3 = new L.Point(60, -20),
p4 = new L.Point(-40, -40);
p2 = new L.Point(-40, 20),
p3 = new L.Point(60, -20),
p4 = new L.Point(-40, -40);
expect(p1.contains(p2)).to.be(true);
expect(p1.contains(p3)).to.be(false);

View File

@ -18,7 +18,7 @@
fg2.addLayer(marker);
var wasClicked1,
wasClicked2;
wasClicked2;
fg2.on('click', function (e) {
expect(e.layer).to.be(marker);

View File

@ -247,8 +247,8 @@ describe("L.LayerGroup#toGeoJSON", function () {
it("returns a 3D FeatureCollection object", function () {
var marker = new L.Marker([10, 20, 30]),
polyline = new L.Polyline([[10, 20, 30], [2, 5, 10]]),
layerGroup = new L.LayerGroup([marker, polyline]);
polyline = new L.Polyline([[10, 20, 30], [2, 5, 10]]),
layerGroup = new L.LayerGroup([marker, polyline]);
expect(layerGroup.toGeoJSON()).to.eql({
type: 'FeatureCollection',
features: [marker.toGeoJSON(), polyline.toGeoJSON()]

View File

@ -11,7 +11,7 @@
describe("#addLayer", function () {
it('adds a layer', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]);
marker = L.marker([0, 0]);
expect(lg.addLayer(marker)).to.eql(lg);
@ -22,7 +22,7 @@
describe("#removeLayer", function () {
it('removes a layer', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]);
marker = L.marker([0, 0]);
lg.addLayer(marker);
expect(lg.removeLayer(marker)).to.eql(lg);
@ -34,7 +34,7 @@
describe("#clearLayers", function () {
it('removes all layers', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]);
marker = L.marker([0, 0]);
lg.addLayer(marker);
expect(lg.clearLayers()).to.eql(lg);
@ -46,7 +46,7 @@
describe("#getLayers", function () {
it('gets all layers', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]);
marker = L.marker([0, 0]);
lg.addLayer(marker);
@ -57,8 +57,8 @@
describe("#eachLayer", function () {
it('iterates over all layers', function () {
var lg = L.layerGroup(),
marker = L.marker([0, 0]),
ctx = {foo: 'bar'};
marker = L.marker([0, 0]),
ctx = {foo: 'bar'};
lg.addLayer(marker);

View File

@ -200,10 +200,11 @@ describe('Popup', function () {
L.Icon.Default.prototype.options.popupAnchor = [0, 0];
var latlng = new L.LatLng(55.8, 37.6),
offset = new L.Point(20, 30),
icon = new L.DivIcon({popupAnchor: offset}),
marker1 = new L.Marker(latlng),
marker2 = new L.Marker(latlng, {icon: icon});
offset = new L.Point(20, 30),
icon = new L.DivIcon({popupAnchor: offset}),
marker1 = new L.Marker(latlng),
marker2 = new L.Marker(latlng, {icon: icon});
marker1.bindPopup('Popup').addTo(map);
marker1.openPopup();
var defaultLeft = parseInt(marker1._popup._container.style.left, 10);

View File

@ -1,9 +1,9 @@
describe("Marker", function () {
var map,
spy,
div,
icon1,
icon2;
spy,
div,
icon1,
icon2;
beforeEach(function () {
div = document.createElement('div');

View File

@ -51,7 +51,7 @@ describe('GridLayer', function () {
for (var i = 0; i < tiles.length; i++) {
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];
}
@ -111,7 +111,7 @@ describe('GridLayer', function () {
var layer = L.gridLayer().addTo(map);
var onAdd = layer.onAdd,
onAddSpy = sinon.spy();
onAddSpy = sinon.spy();
layer.onAdd = function () {
onAdd.apply(this, arguments);
onAddSpy();
@ -129,7 +129,7 @@ describe('GridLayer', function () {
describe("when a tilelayer is added to a map with no other layers", function () {
it("has the same zoomlevels as the tilelayer", function () {
var maxZoom = 10,
minZoom = 5;
minZoom = 5;
map.setView([0, 0], 1);

View File

@ -37,11 +37,8 @@ describe('Polygon', function () {
it("can be initialized with holes", function () {
var originalLatLngs = [
[ //external ring
[0, 10], [10, 10], [10, 0]
], [ //hole
[2, 3], [2, 4], [3, 4]
]
[[0, 10], [10, 10], [10, 0]], // external ring
[[2, 3], [2, 4], [3, 4]] // hole
];
var polygon = new L.Polygon(originalLatLngs);
@ -116,11 +113,8 @@ describe('Polygon', function () {
it("can be set external ring and holes", function () {
var latLngs = [
[ //external ring
[0, 10], [10, 10], [10, 0]
], [ //hole
[2, 3], [2, 4], [3, 4]
]
[[0, 10], [10, 10], [10, 0]], // external ring
[[2, 3], [2, 4], [3, 4]] // hole
];
var polygon = new L.Polygon([]);
@ -207,10 +201,8 @@ describe('Polygon', function () {
it("should return first latlngs on a multipolygon with hole", function () {
var latlngs = [
[
[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([0, 10]), L.latLng([10, 10]), L.latLng([10, 0])],
[L.latLng([2, 3]), L.latLng([2, 4]), L.latLng([3, 4])]],
[[L.latLng([10, 20]), L.latLng([30, 40]), L.latLng([50, 60])]]
];

View File

@ -1,6 +1,6 @@
describe("Map", function () {
var map,
spy;
spy;
beforeEach(function () {
map = L.map(document.createElement('div'));
});
@ -9,7 +9,7 @@ describe("Map", function () {
it("fires an unload event if loaded", function () {
var container = document.createElement('div'),
map = new L.Map(container).setView([0, 0], 0),
spy = sinon.spy();
spy = sinon.spy();
map.on('unload', spy);
map.remove();
expect(spy.called).to.be.ok();
@ -18,7 +18,7 @@ describe("Map", function () {
it("fires no unload event if not loaded", function () {
var container = document.createElement('div'),
map = new L.Map(container),
spy = sinon.spy();
spy = sinon.spy();
map.on('unload', spy);
map.remove();
expect(spy.called).not.to.be.ok();
@ -27,7 +27,7 @@ describe("Map", function () {
describe("corner case checking", function () {
it("throws an exception upon reinitialization", function () {
var container = document.createElement('div'),
map = new L.Map(container);
map = new L.Map(container);
expect(function () {
L.map(container);
}).to.throwException(function (e) {
@ -56,7 +56,7 @@ describe("Map", function () {
it("unbinds events", function () {
var container = document.createElement('div'),
map = new L.Map(container).setView([0, 0], 1),
spy = sinon.spy();
spy = sinon.spy();
map.on('click dblclick mousedown mouseup mousemove', spy);
map.remove();
@ -443,7 +443,7 @@ describe("Map", function () {
it("fires a zoomlevelschange event", function () {
map.whenReady(function () {
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);
map.on("zoomlevelschange", spy);
@ -480,7 +480,7 @@ describe("Map", function () {
it("calls the provided function for each layer", function () {
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
t2 = L.tileLayer("{z}{x}{y}").addTo(map),
spy = sinon.spy();
spy = sinon.spy();
map.eachLayer(spy);
@ -491,7 +491,7 @@ describe("Map", function () {
it("calls the provided function with the provided context", function () {
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
spy = sinon.spy();
spy = sinon.spy();
map.eachLayer(spy, map);
@ -502,7 +502,7 @@ describe("Map", function () {
describe("#invalidateSize", function () {
var container,
origWidth = 100,
clock;
clock;
beforeEach(function () {
container = map.getContainer();
@ -604,15 +604,15 @@ describe("Map", function () {
it('move to requested center and zoom, and call zoomend once', function (done) {
var spy = sinon.spy(),
newCenter = new L.LatLng(10, 11),
newZoom = 12,
callback = function () {
expect(map.getCenter()).to.eql(newCenter);
expect(map.getZoom()).to.eql(newZoom);
spy();
expect(spy.calledOnce).to.be.ok();
done();
};
newCenter = new L.LatLng(10, 11),
newZoom = 12;
var callback = function () {
expect(map.getCenter()).to.eql(newCenter);
expect(map.getZoom()).to.eql(newZoom);
spy();
expect(spy.calledOnce).to.be.ok();
done();
};
map.setView([0, 0], 0);
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 () {
var mapSpy = sinon.spy(),
layerSpy = sinon.spy(),
otherSpy = sinon.spy();
layerSpy = sinon.spy(),
otherSpy = sinon.spy();
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);
map.on("mouseout", mapSpy);
@ -710,8 +710,8 @@ describe("Map", function () {
it("mouseout is not forwared to layers if fired on the map", function () {
var mapSpy = sinon.spy(),
layerSpy = sinon.spy(),
otherSpy = sinon.spy();
layerSpy = sinon.spy(),
otherSpy = sinon.spy();
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);
map.on("mouseout", mapSpy);

View File

@ -1,33 +1,33 @@
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, {
dragging: true
});
var container = document.createElement('div');
var 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);
});
it("calls the map with dragging and worldCopyJump enabled", function () {
var container = document.createElement('div'),
map = new L.Map(container, {
dragging: true,
worldCopyJump: true
});
var container = document.createElement('div');
var 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, {
dragging: false,
worldCopyJump: true
});
"enables dragging after setting center and zoom", function () {
var container = document.createElement('div');
var map = new L.Map(container, {
dragging: false,
worldCopyJump: true
});
expect(map.dragging.enabled()).to.be(false);
map.setView([0, 0], 0);