From 3f3b287d6268916856ef72412f9ba6024537928e Mon Sep 17 00:00:00 2001
From: Kushan Joshi <0o3ko0@gmail.com>
Date: Wed, 15 Jun 2016 18:16:18 +0530
Subject: [PATCH] Remove linting errors `spec/services`
---
test/spec/services/mapillary.js | 8 +-
test/spec/services/nominatim.js | 58 +++++------
test/spec/services/taginfo.js | 179 ++++++++++++++++----------------
3 files changed, 122 insertions(+), 123 deletions(-)
diff --git a/test/spec/services/mapillary.js b/test/spec/services/mapillary.js
index 7294b26ee..087075a70 100644
--- a/test/spec/services/mapillary.js
+++ b/test/spec/services/mapillary.js
@@ -23,7 +23,7 @@ describe('iD.services.mapillary', function() {
expect(cache).to.have.property('images');
expect(cache).to.have.property('signs');
- var mapillary2 = iD.services.mapillary();
+ iD.services.mapillary();
var cache2 = iD.services.mapillary.cache;
expect(cache).to.equal(cache2);
});
@@ -98,7 +98,7 @@ describe('iD.services.mapillary', function() {
var match0 = /page=0/,
response0 = { type: 'FeatureCollection', features: features0 },
match1 = /page=1/,
- response1 = { type: 'FeatureCollection', features: features1 }
+ response1 = { type: 'FeatureCollection', features: features1 };
server.respondWith('GET', match0,
[200, { 'Content-Type': 'application/json' }, JSON.stringify(response0) ]);
@@ -231,7 +231,7 @@ describe('iD.services.mapillary', function() {
var match0 = /page=0/,
response0 = { type: 'FeatureCollection', features: features0 },
match1 = /page=1/,
- response1 = { type: 'FeatureCollection', features: features1 }
+ response1 = { type: 'FeatureCollection', features: features1 };
server.respondWith('GET', match0,
[200, { 'Content-Type': 'application/json' }, JSON.stringify(response0) ]);
@@ -356,7 +356,7 @@ describe('iD.services.mapillary', function() {
}]
};
- expect(mapillary.signHTML(signdata)).to.eql('65')
+ expect(mapillary.signHTML(signdata)).to.eql('65');
});
});
diff --git a/test/spec/services/nominatim.js b/test/spec/services/nominatim.js
index e77dbd725..af9dcd835 100644
--- a/test/spec/services/nominatim.js
+++ b/test/spec/services/nominatim.js
@@ -1,4 +1,4 @@
-describe("iD.services.nominatim", function() {
+describe('iD.services.nominatim', function() {
var server, nominatim;
beforeEach(function() {
@@ -15,84 +15,84 @@ describe("iD.services.nominatim", function() {
return iD.util.stringQs(url.substring(url.indexOf('?') + 1));
}
- describe("#countryCode", function() {
- it("calls the given callback with the results of the country code query", function() {
+ describe('#countryCode', function() {
+ it('calls the given callback with the results of the country code query', function() {
var callback = sinon.spy();
nominatim.countryCode([16, 48], callback);
- server.respondWith("GET", "https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=48&lon=16",
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', 'https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=48&lon=16',
+ [200, { 'Content-Type': 'application/json' },
'{"address":{"country_code":"at"}}']);
server.respond();
expect(query(server.requests[0].url)).to.eql(
- {format: "json", addressdetails: "1", lat: "48", lon: "16"});
- expect(callback).to.have.been.calledWith(null, "at");
+ {format: 'json', addressdetails: '1', lat: '48', lon: '16'});
+ expect(callback).to.have.been.calledWith(null, 'at');
});
- it("should not cache the first country code result", function() {
+ it('should not cache the first country code result', function() {
var callback = sinon.spy();
nominatim.countryCode([16, 48], callback);
- server.respondWith("GET", "https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=48&lon=16",
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', 'https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=48&lon=16',
+ [200, { 'Content-Type': 'application/json' },
'{"address":{"country_code":"at"}}']);
server.respond();
expect(query(server.requests[0].url)).to.eql(
- {format: "json", addressdetails: "1", lat: "48", lon: "16"});
- expect(callback).to.have.been.calledWith(null, "at");
+ {format: 'json', addressdetails: '1', lat: '48', lon: '16'});
+ expect(callback).to.have.been.calledWith(null, 'at');
server.restore();
server = sinon.fakeServer.create();
nominatim.countryCode([17, 49], callback);
- server.respondWith("GET", "https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=49&lon=17",
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', 'https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=49&lon=17',
+ [200, { 'Content-Type': 'application/json' },
'{"address":{"country_code":"cz"}}']);
server.respond();
expect(query(server.requests[0].url)).to.eql(
- {format: "json", addressdetails: "1", lat: "49", lon: "17"});
- expect(callback).to.have.been.calledWith(null, "cz");
+ {format: 'json', addressdetails: '1', lat: '49', lon: '17'});
+ expect(callback).to.have.been.calledWith(null, 'cz');
});
- it("should cache the first country code result", function() {
+ it('should cache the first country code result', function() {
var callback = sinon.spy();
nominatim.countryCode([16, 48], callback);
- server.respondWith("GET", "https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=48&lon=16",
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', 'https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=48&lon=16',
+ [200, { 'Content-Type': 'application/json' },
'{"address":{"country_code":"at"}}']);
server.respond();
expect(query(server.requests[0].url)).to.eql(
- {format: "json", addressdetails: "1", lat: "48", lon: "16"});
- expect(callback).to.have.been.calledWith(null, "at");
+ {format: 'json', addressdetails: '1', lat: '48', lon: '16'});
+ expect(callback).to.have.been.calledWith(null, 'at');
server.restore();
server = sinon.fakeServer.create();
nominatim.countryCode([16.01, 48.01], callback);
- server.respondWith("GET", "https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=48.01&lon=16.01",
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', 'https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=48.01&lon=16.01',
+ [200, { 'Content-Type': 'application/json' },
'{"address":{"country_code":"cz"}}']);
server.respond();
- expect(callback).to.have.been.calledWith(null, "at");
+ expect(callback).to.have.been.calledWith(null, 'at');
});
- it("calls the given callback with an error", function() {
+ it('calls the given callback with an error', function() {
var callback = sinon.spy();
nominatim.countryCode([1000, 1000], callback);
- server.respondWith("GET", "https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=1000&lon=1000",
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', 'https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&lat=1000&lon=1000',
+ [200, { 'Content-Type': 'application/json' },
'{"error":"Unable to geocode"}']);
server.respond();
expect(query(server.requests[0].url)).to.eql(
- {format: "json", addressdetails: "1", lat: "1000", lon: "1000"});
- expect(callback).to.have.been.calledWith("Unable to geocode");
+ {format: 'json', addressdetails: '1', lat: '1000', lon: '1000'});
+ expect(callback).to.have.been.calledWith('Unable to geocode');
});
});
});
diff --git a/test/spec/services/taginfo.js b/test/spec/services/taginfo.js
index bc65db96e..e28bf76a2 100644
--- a/test/spec/services/taginfo.js
+++ b/test/spec/services/taginfo.js
@@ -1,4 +1,4 @@
-describe("iD.services.taginfo", function() {
+describe('iD.services.taginfo', function() {
var server, taginfo;
beforeEach(function() {
@@ -14,181 +14,180 @@ describe("iD.services.taginfo", function() {
return iD.util.stringQs(url.substring(url.indexOf('?') + 1));
}
- describe("#keys", function() {
- it("calls the given callback with the results of the keys query", function() {
+ describe('#keys', function() {
+ it('calls the given callback with the results of the keys query', function() {
var callback = sinon.spy();
- taginfo.keys({query: "amen"}, callback);
+ taginfo.keys({query: 'amen'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/keys/all"),
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/keys/all'),
+ [200, { 'Content-Type': 'application/json' },
'{"data":[{"count_all":5190337,"key":"amenity","count_all_fraction":1.0}]}']);
server.respond();
expect(query(server.requests[0].url)).to.eql(
- {query: "amen", page: "1", rp: "10", sortname: "count_all", sortorder: "desc"});
- expect(callback).to.have.been.calledWith(null, [{"title":"amenity", "value":"amenity"}]);
+ {query: 'amen', page: '1', rp: '10', sortname: 'count_all', sortorder: 'desc'});
+ expect(callback).to.have.been.calledWith(null, [{'title':'amenity', 'value':'amenity'}]);
});
- it("includes popular keys", function() {
+ it('includes popular keys', function() {
var callback = sinon.spy();
- taginfo.keys({query: "amen"}, callback);
+ taginfo.keys({query: 'amen'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/keys/all"),
- [200, { "Content-Type": "application/json" },
- '{"data":[{"count_all":5190337,"key":"amenity","count_all_fraction":1.0, "count_nodes_fraction":1.0},\
- {"count_all":1,"key":"amenityother","count_all_fraction":0.0, "count_nodes_fraction":0.0}]}']);
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/keys/all'),
+ [200, { 'Content-Type': 'application/json' },
+ '{"data":[{"count_all":5190337,"key":"amenity","count_all_fraction":1.0, "count_nodes_fraction":1.0},'
+ + '{"count_all":1,"key":"amenityother","count_all_fraction":0.0, "count_nodes_fraction":0.0}]}']);
server.respond();
- expect(callback).to.have.been.calledWith(null, [{"title":"amenity", "value":"amenity"}]);
+ expect(callback).to.have.been.calledWith(null, [{'title':'amenity', 'value':'amenity'}]);
});
- it("includes popular keys with an entity type filter", function() {
+ it('includes popular keys with an entity type filter', function() {
var callback = sinon.spy();
- taginfo.keys({query: "amen", filter: "nodes"}, callback);
+ taginfo.keys({query: 'amen', filter: 'nodes'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/keys/all"),
- [200, { "Content-Type": "application/json" },
- '{"data":[{"count_all":5190337,"count_nodes":500000,"key":"amenity","count_all_fraction":1.0, "count_nodes_fraction":1.0},\
- {"count_all":1,"key":"amenityother","count_all_fraction":0.0, "count_nodes":100}]}']);
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/keys/all'),
+ [200, { 'Content-Type': 'application/json' },
+ '{"data":[{"count_all":5190337,"count_nodes":500000,"key":"amenity","count_all_fraction":1.0, "count_nodes_fraction":1.0},'
+ + '{"count_all":1,"key":"amenityother","count_all_fraction":0.0, "count_nodes":100}]}']);
server.respond();
- expect(callback).to.have.been.calledWith(null, [{"title":"amenity", "value":"amenity"}]);
+ expect(callback).to.have.been.calledWith(null, [{'title':'amenity', 'value':'amenity'}]);
});
- it("includes unpopular keys with a wiki page", function() {
+ it('includes unpopular keys with a wiki page', function() {
var callback = sinon.spy();
- taginfo.keys({query: "amen"}, callback);
+ taginfo.keys({query: 'amen'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/keys/all"),
- [200, { "Content-Type": "application/json" },
- '{"data":[{"count_all":5190337,"key":"amenity","count_all_fraction":1.0, "count_nodes_fraction":1.0},\
- {"count_all":1,"key":"amenityother","count_all_fraction":0.0, "count_nodes_fraction":0.0, "in_wiki": true}]}']);
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/keys/all'),
+ [200, { 'Content-Type': 'application/json' },
+ '{"data":[{"count_all":5190337,"key":"amenity","count_all_fraction":1.0, "count_nodes_fraction":1.0},'
+ + '{"count_all":1,"key":"amenityother","count_all_fraction":0.0, "count_nodes_fraction":0.0, "in_wiki": true}]}']);
server.respond();
expect(callback).to.have.been.calledWith(null, [
- {"title":"amenity", "value":"amenity"},
- {"title":"amenityother", "value":"amenityother"}
+ {'title':'amenity', 'value':'amenity'},
+ {'title':'amenityother', 'value':'amenityother'}
]);
});
- it("sorts keys with ':' below keys without ':'", function() {
+ it('sorts keys with \':\' below keys without \':\'', function() {
var callback = sinon.spy();
- taginfo.keys({query: "ref"}, callback);
+ taginfo.keys({query: 'ref'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/keys/all"),
- [200, { "Content-Type": "application/json" },
- '{"data":[{"key":"ref:bag","count_all":9790586,"count_all_fraction":0.0028},\
- {"key":"ref","count_all":7933528,"count_all_fraction":0.0023}]}']);
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/keys/all'),
+ [200, { 'Content-Type': 'application/json' },
+ '{"data":[{"key":"ref:bag","count_all":9790586,"count_all_fraction":0.0028},{"key":"ref","count_all":7933528,"count_all_fraction":0.0023}]}']);
server.respond();
- expect(callback).to.have.been.calledWith(null, [{"title":"ref", "value":"ref"},{"title":"ref:bag", "value":"ref:bag"}]);
+ expect(callback).to.have.been.calledWith(null, [{'title':'ref', 'value':'ref'},{'title':'ref:bag', 'value':'ref:bag'}]);
});
});
- describe("#multikeys", function() {
- it("calls the given callback with the results of the multikeys query", function() {
+ describe('#multikeys', function() {
+ it('calls the given callback with the results of the multikeys query', function() {
var callback = sinon.spy();
- taginfo.multikeys({query: "recycling:"}, callback);
+ taginfo.multikeys({query: 'recycling:'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/keys/all"),
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/keys/all'),
+ [200, { 'Content-Type': 'application/json' },
'{"data":[{"count_all":69593,"key":"recycling:glass","count_all_fraction":0.0}]}']);
server.respond();
expect(query(server.requests[0].url)).to.eql(
- {query: "recycling:", page: "1", rp: "25", sortname: "count_all", sortorder: "desc"});
- expect(callback).to.have.been.calledWith(null, [{"title":"recycling:glass", "value":"recycling:glass"}]);
+ {query: 'recycling:', page: '1', rp: '25', sortname: 'count_all', sortorder: 'desc'});
+ expect(callback).to.have.been.calledWith(null, [{'title':'recycling:glass', 'value':'recycling:glass'}]);
});
- it("excludes multikeys with extra colons", function() {
+ it('excludes multikeys with extra colons', function() {
var callback = sinon.spy();
- taginfo.multikeys({query: "recycling:"}, callback);
+ taginfo.multikeys({query: 'recycling:'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/keys/all"),
- [200, { "Content-Type": "application/json" },
- '{"data":[{"count_all":69593,"key":"recycling:glass","count_all_fraction":0.0},\
- {"count_all":22,"key":"recycling:glass:color","count_all_fraction":0.0}]}']);
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/keys/all'),
+ [200, { 'Content-Type': 'application/json' },
+ '{"data":[{"count_all":69593,"key":"recycling:glass","count_all_fraction":0.0},'
+ + '{"count_all":22,"key":"recycling:glass:color","count_all_fraction":0.0}]}']);
server.respond();
- expect(callback).to.have.been.calledWith(null, [{"title":"recycling:glass", "value":"recycling:glass"}]);
+ expect(callback).to.have.been.calledWith(null, [{'title':'recycling:glass', 'value':'recycling:glass'}]);
});
});
- describe("#values", function() {
- it("calls the given callback with the results of the values query", function() {
+ describe('#values', function() {
+ it('calls the given callback with the results of the values query', function() {
var callback = sinon.spy();
- taginfo.values({key: "amenity", query: "par"}, callback);
+ taginfo.values({key: 'amenity', query: 'par'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/key/values"),
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'),
+ [200, { 'Content-Type': 'application/json' },
'{"data":[{"value":"parking","description":"A place for parking cars", "fraction":0.1}]}']);
server.respond();
expect(query(server.requests[0].url)).to.eql(
- {key: "amenity", query: "par", page: "1", rp: "25", sortname: 'count_all', sortorder: 'desc'});
- expect(callback).to.have.been.calledWith(null, [{"value":"parking","title":"A place for parking cars"}]);
+ {key: 'amenity', query: 'par', page: '1', rp: '25', sortname: 'count_all', sortorder: 'desc'});
+ expect(callback).to.have.been.calledWith(null, [{'value':'parking','title':'A place for parking cars'}]);
});
- it("includes popular values", function() {
+ it('includes popular values', function() {
var callback = sinon.spy();
- taginfo.values({key: "amenity", query: "par"}, callback);
+ taginfo.values({key: 'amenity', query: 'par'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/key/values"),
- [200, { "Content-Type": "application/json" },
- '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":1.0},\
- {"value":"party","description":"A place for partying", "fraction":0.0}]}']);
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'),
+ [200, { 'Content-Type': 'application/json' },
+ '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":1.0},' +
+ '{"value":"party","description":"A place for partying", "fraction":0.0}]}']);
server.respond();
- expect(callback).to.have.been.calledWith(null, [{"value":"parking","title":"A place for parking cars"}]);
+ expect(callback).to.have.been.calledWith(null, [{'value':'parking','title':'A place for parking cars'}]);
});
- it("includes unpopular values with a wiki page", function() {
+ it('includes unpopular values with a wiki page', function() {
var callback = sinon.spy();
- taginfo.values({key: "amenity", query: "par"}, callback);
+ taginfo.values({key: 'amenity', query: 'par'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/key/values"),
- [200, { "Content-Type": "application/json" },
- '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":1.0},\
- {"value":"party","description":"A place for partying", "fraction":0.0, "in_wiki": true}]}']);
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'),
+ [200, { 'Content-Type': 'application/json' },
+ '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":1.0},'
+ + '{"value":"party","description":"A place for partying", "fraction":0.0, "in_wiki": true}]}']);
server.respond();
expect(callback).to.have.been.calledWith(null, [
- {"value":"parking","title":"A place for parking cars"},
- {"value":"party","title":"A place for partying"}
+ {'value':'parking','title':'A place for parking cars'},
+ {'value':'party','title':'A place for partying'}
]);
});
- it("excludes values with capital letters and some punctuation", function() {
+ it('excludes values with capital letters and some punctuation', function() {
var callback = sinon.spy();
- taginfo.values({key: "amenity", query: "par"}, callback);
+ taginfo.values({key: 'amenity', query: 'par'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/key/values"),
- [200, { "Content-Type": "application/json" },
- '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":0.2},\
- {"value":"PArking","description":"A common mispelling", "fraction":0.2},\
- {"value":"parking;partying","description":"A place for parking cars *and* partying", "fraction":0.2},\
- {"value":"parking, partying","description":"A place for parking cars *and* partying", "fraction":0.2},\
- {"value":"*","description":"", "fraction":0.2}]}']);
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'),
+ [200, { 'Content-Type': 'application/json' },
+ '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":0.2},'
+ + '{"value":"PArking","description":"A common mispelling", "fraction":0.2},'
+ + '{"value":"parking;partying","description":"A place for parking cars *and* partying", "fraction":0.2},'
+ + '{"value":"parking, partying","description":"A place for parking cars *and* partying", "fraction":0.2},'
+ + '{"value":"*","description":"", "fraction":0.2}]}']);
server.respond();
- expect(callback).to.have.been.calledWith(null, [{"value":"parking","title":"A place for parking cars"}]);
+ expect(callback).to.have.been.calledWith(null, [{'value':'parking','title':'A place for parking cars'}]);
});
});
- describe("#docs", function() {
- it("calls the given callback with the results of the docs query", function() {
+ describe('#docs', function() {
+ it('calls the given callback with the results of the docs query', function() {
var callback = sinon.spy();
- taginfo.docs({key: "amenity", value: "parking"}, callback);
+ taginfo.docs({key: 'amenity', value: 'parking'}, callback);
- server.respondWith("GET", new RegExp("https://taginfo.openstreetmap.org/api/4/tag/wiki_page"),
- [200, { "Content-Type": "application/json" },
+ server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/tag/wiki_page'),
+ [200, { 'Content-Type': 'application/json' },
'{"data":[{"on_way":false,"lang":"en","on_area":true,"image":"File:Car park2.jpg"}]}']);
server.respond();
expect(query(server.requests[0].url)).to.eql(
- {key: "amenity", value: "parking"});
+ {key: 'amenity', value: 'parking'});
expect(callback).to.have.been.calledWith(null,
- [{"on_way":false,"lang":"en","on_area":true,"image":"File:Car park2.jpg"}]);
+ [{'on_way':false,'lang':'en','on_area':true,'image':'File:Car park2.jpg'}]);
});
});