lib/leaflet/spec/suites/SpecHelper.js in leaflet-js-0.6.beta4 vs lib/leaflet/spec/suites/SpecHelper.js in leaflet-js-0.7.0

- old
+ new

@@ -1,26 +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; - }; -} \ No newline at end of file + 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.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); +};