From 6d580f66c29548ccf96416ebc3f5642ee1116994 Mon Sep 17 00:00:00 2001 From: Kushan Joshi <0o3ko0@gmail.com> Date: Wed, 15 Jun 2016 18:36:48 +0530 Subject: [PATCH] Remaining files and add `eslint test/spec` to package.json --- package.json | 5 ++--- test/{spec => }/.eslintrc | 3 ++- test/spec/geo.js | 4 ++-- test/spec/presets.js | 32 ++++++++++++++++---------------- test/spec/spec_helpers.js | 4 +++- test/spec/svg.js | 10 +++++----- 6 files changed, 30 insertions(+), 28 deletions(-) rename test/{spec => }/.eslintrc (85%) diff --git a/package.json b/package.json index 207cfd706..90f35873c 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,8 @@ "scripts": { "test": "npm run lint && phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html dot && make && phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index_packaged.html dot", "start": "http-server .", - "lint": "eslint js/id && npm run lint:spec", - "lint:modules": "eslint modules", - "lint:spec": "eslint test/spec/actions test/spec/behavior test/spec/core test/spec/geo test/spec/lib test/spec/presets test/spec/modes test/spec/renderer test/spec/svg test/spec/ui test/spec/util" + "lint": "eslint js/id test/spec", + "lint:modules": "eslint modules" }, "repository": { "type": "git", diff --git a/test/spec/.eslintrc b/test/.eslintrc similarity index 85% rename from test/spec/.eslintrc rename to test/.eslintrc index 94c7b0c84..cc5c83a3e 100644 --- a/test/spec/.eslintrc +++ b/test/.eslintrc @@ -8,7 +8,8 @@ "afterEach": true, "mocha": true, "sinon": true, - "happen": true + "happen": true, + "before": true, }, "rules": { "no-unused-expressions": 0 diff --git a/test/spec/geo.js b/test/spec/geo.js index 854caf984..c42062c99 100644 --- a/test/spec/geo.js +++ b/test/spec/geo.js @@ -194,7 +194,7 @@ describe('iD.geo', function() { index: undefined, distance: Infinity, loc: undefined - }) + }); }); it('returns undefined properties for a degenerate way (single node)', function() { @@ -202,7 +202,7 @@ describe('iD.geo', function() { index: undefined, distance: Infinity, loc: undefined - }) + }); }); it('calculates the orthogonal projection of a point onto a segment', function() { diff --git a/test/spec/presets.js b/test/spec/presets.js index c77f6d377..8e8be586e 100644 --- a/test/spec/presets.js +++ b/test/spec/presets.js @@ -1,4 +1,4 @@ -describe("iD.presets.presets", function() { +describe('iD.presets.presets', function() { var p = { point: { tags: {}, @@ -24,14 +24,14 @@ describe("iD.presets.presets", function() { var c = iD.presets.presets().load({presets: p}); - describe("#match", function() { - it("returns a collection containing presets matching a geometry and tags", function() { + describe('#match', function() { + it('returns a collection containing presets matching a geometry and tags', function() { var way = iD.Way({tags: { highway: 'residential'}}), graph = iD.Graph([way]); expect(c.match(way, graph).id).to.eql('residential'); }); - it("returns the appropriate fallback preset when no tags match", function() { + it('returns the appropriate fallback preset when no tags match', function() { var point = iD.Node(), line = iD.Way({tags: {foo: 'bar'}}), graph = iD.Graph([point, line]); @@ -40,7 +40,7 @@ describe("iD.presets.presets", function() { }); }); - describe("#areaKeys", function() { + describe('#areaKeys', function() { var presets = iD.presets.presets().load({ presets: { 'amenity/fuel/shell': { @@ -75,57 +75,57 @@ describe("iD.presets.presets", function() { } }); - it("whitelists keys for presets with area geometry", function() { + it('whitelists keys for presets with area geometry', function() { expect(presets.areaKeys()).to.include.keys('natural'); }); - it("blacklists key-values for presets with a line geometry", function() { + it('blacklists key-values for presets with a line geometry', function() { expect(presets.areaKeys().natural).to.include.keys('tree_row'); expect(presets.areaKeys().natural.tree_row).to.be.true; }); - it("does not blacklist key-values for presets with both area and line geometry", function() { + it('does not blacklist key-values for presets with both area and line geometry', function() { expect(presets.areaKeys().golf).not.to.include.keys('water_hazard'); }); - it("does not blacklist key-values for presets with neither area nor line geometry", function() { + it('does not blacklist key-values for presets with neither area nor line geometry', function() { expect(presets.areaKeys().natural).not.to.include.keys('peak'); }); - it("does not blacklist generic '*' key-values", function() { + it('does not blacklist generic \'*\' key-values', function() { expect(presets.areaKeys().natural).not.to.include.keys('natural'); }); - it("ignores keys like 'highway' that are assumed to be lines", function() { + it('ignores keys like \'highway\' that are assumed to be lines', function() { expect(presets.areaKeys()).not.to.include.keys('highway'); }); - it("ignores suggestion presets", function() { + it('ignores suggestion presets', function() { expect(presets.areaKeys()).not.to.include.keys('amenity'); }); }); - describe("expected matches", function() { + describe('expected matches', function() { var presets; before(function() { presets = iD.presets.presets().load(iD.data.presets); }); - it("prefers building to multipolygon", function() { + it('prefers building to multipolygon', function() { var relation = iD.Relation({tags: {type: 'multipolygon', building: 'yes'}}), graph = iD.Graph([relation]); expect(presets.match(relation, graph).id).to.eql('building'); }); - it("prefers building to address", function() { + it('prefers building to address', function() { var way = iD.Way({tags: {area: 'yes', building: 'yes', 'addr:housenumber': '1234'}}), graph = iD.Graph([way]); expect(presets.match(way, graph).id).to.eql('building'); }); - it("prefers pedestrian to area", function() { + it('prefers pedestrian to area', function() { var way = iD.Way({tags: {area: 'yes', highway: 'pedestrian'}}), graph = iD.Graph([way]); expect(presets.match(way, graph).id).to.eql('highway/pedestrian'); diff --git a/test/spec/spec_helpers.js b/test/spec/spec_helpers.js index 2c15b7567..dd0b8a8d9 100644 --- a/test/spec/spec_helpers.js +++ b/test/spec/spec_helpers.js @@ -1,3 +1,5 @@ +/* globals chai */ + iD.debug = true; mocha.setup({ @@ -13,7 +15,7 @@ mocha.setup({ ] }); -var expect = chai.expect; +expect = chai.expect; chai.use(function (chai, utils) { var flag = utils.flag; diff --git a/test/spec/svg.js b/test/spec/svg.js index 56fbb2321..57b056434 100644 --- a/test/spec/svg.js +++ b/test/spec/svg.js @@ -1,18 +1,18 @@ -describe("iD.svg.RelationMemberTags", function() { - it("includes tags from parent multipolygon relations", function() { +describe('iD.svg.RelationMemberTags', function() { + it('includes tags from parent multipolygon relations', function() { var graph = iD.Graph([ iD.Way({id: 'w'}), - iD.Relation({id: 'r', members: [{id: 'w'}], tags: {type: 'multipolygon'}}), + iD.Relation({id: 'r', members: [{id: 'w'}], tags: {type: 'multipolygon'}}) ]); expect(iD.svg.RelationMemberTags(graph)(graph.entity('w'))) .to.eql({type: 'multipolygon'}); }); - it("includes tags from parent boundary relations", function() { + it('includes tags from parent boundary relations', function() { var graph = iD.Graph([ iD.Way({id: 'w'}), - iD.Relation({id: 'r', members: [{id: 'w'}], tags: {type: 'boundary'}}), + iD.Relation({id: 'r', members: [{id: 'w'}], tags: {type: 'boundary'}}) ]); expect(iD.svg.RelationMemberTags(graph)(graph.entity('w')))