From 295b8544eba99e884dfe616d253a8fe3c32e50a1 Mon Sep 17 00:00:00 2001 From: Kushan Joshi <0o3ko0@gmail.com> Date: Wed, 15 Jun 2016 01:47:34 +0530 Subject: [PATCH] Remove linting errors from `spec/modes` & `spec/presets` --- package.json | 4 +-- test/spec/modes/add_point.js | 12 +++---- test/spec/presets/category.js | 18 +++++------ test/spec/presets/collection.js | 30 ++++++++--------- test/spec/presets/preset.js | 57 +++++++++++++++++---------------- 5 files changed, 61 insertions(+), 60 deletions(-) diff --git a/package.json b/package.json index 9fdf0d2ed..7a946e876 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,9 @@ "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:actions", + "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" + "lint:spec": "eslint test/spec/actions test/spec/behavior test/spec/core test/spec/geo test/spec/lib test/spec/presets test/spec/modes" }, "repository": { "type": "git", diff --git a/test/spec/modes/add_point.js b/test/spec/modes/add_point.js index 4f90feefd..516dc56f8 100644 --- a/test/spec/modes/add_point.js +++ b/test/spec/modes/add_point.js @@ -1,4 +1,4 @@ -describe("iD.modes.AddPoint", function() { +describe('iD.modes.AddPoint', function() { var context; beforeEach(function() { @@ -19,8 +19,8 @@ describe("iD.modes.AddPoint", function() { context.enter(iD.modes.AddPoint(context)); }); - describe("clicking the map", function () { - it("adds a node", function() { + describe('clicking the map', function () { + it('adds a node', function() { happen.mousedown(context.surface().node(), {}); happen.mouseup(window, {}); expect(context.changes().created).to.have.length(1); @@ -28,7 +28,7 @@ describe("iD.modes.AddPoint", function() { d3.select('window').on('click.draw-block', null); }); - it("selects the node", function() { + it('selects the node', function() { happen.mousedown(context.surface().node(), {}); happen.mouseup(window, {}); expect(context.mode().id).to.equal('select'); @@ -37,8 +37,8 @@ describe("iD.modes.AddPoint", function() { }); }); - describe("pressing ⎋", function() { - it("exits to browse mode", function(done) { + describe('pressing ⎋', function() { + it('exits to browse mode', function(done) { happen.keydown(document, {keyCode: 27}); window.setTimeout(function() { expect(context.mode().id).to.equal('browse'); diff --git a/test/spec/presets/category.js b/test/spec/presets/category.js index 94dd034f7..1cd7db4a9 100644 --- a/test/spec/presets/category.js +++ b/test/spec/presets/category.js @@ -1,13 +1,13 @@ -describe("iD.presets.Category", function() { +describe('iD.presets.Category', function() { var category, residential; beforeEach(function() { category = { - "geometry": "line", - "icon": "highway", - "name": "roads", - "members": [ - "highway/residential" + 'geometry': 'line', + 'icon': 'highway', + 'name': 'roads', + 'members': [ + 'highway/residential' ] }; residential = iD.presets.Preset('highway/residential', { @@ -18,13 +18,13 @@ describe("iD.presets.Category", function() { }); }); - it("maps members names to preset instances", function() { + it('maps members names to preset instances', function() { var c = iD.presets.Category('road', category, iD.presets.Collection([residential])); expect(c.members.collection[0]).to.eql(residential); }); - describe("#matchGeometry", function() { - it("matches the type of an entity", function() { + describe('#matchGeometry', function() { + it('matches the type of an entity', function() { var c = iD.presets.Category('road', category, iD.presets.Collection([residential])), w = iD.Way(), n = iD.Node(), diff --git a/test/spec/presets/collection.js b/test/spec/presets/collection.js index 3307efc6c..815c10d39 100644 --- a/test/spec/presets/collection.js +++ b/test/spec/presets/collection.js @@ -1,4 +1,4 @@ -describe("iD.presets.Collection", function() { +describe('iD.presets.Collection', function() { var p = { point: iD.presets.Preset('point', { @@ -28,40 +28,40 @@ describe("iD.presets.Collection", function() { w = iD.Way({ tags: { highway: 'residential' }}), g = iD.Graph().replace(w); - describe("#item", function() { - it("fetches a preset by id", function() { + describe('#item', function() { + it('fetches a preset by id', function() { expect(c.item('highway/residential')).to.equal(p.residential); }); }); - describe("#matchGeometry", function() { - it("returns a new collection only containing presets matching a geometry", function() { + describe('#matchGeometry', function() { + it('returns a new collection only containing presets matching a geometry', function() { expect(c.matchGeometry('area').collection).to.eql([p.area, p.park]); }); }); - describe("#search", function() { - it("filters presets by name", function() { - expect(c.search("resid", "line").collection.indexOf(p.residential) >= 0).to.eql(true); + describe('#search', function() { + it('filters presets by name', function() { + expect(c.search('resid', 'line').collection.indexOf(p.residential) >= 0).to.eql(true); }); - it("is fuzzy", function() { - expect(c.search("rusid", "line").collection.indexOf(p.residential) >= 0).to.eql(true); + it('is fuzzy', function() { + expect(c.search('rusid', 'line').collection.indexOf(p.residential) >= 0).to.eql(true); }); - it("includes the appropriate fallback preset", function() { - expect(c.search("blade of grass", "point").collection.indexOf(p.point) >= 0).to.eql(true); - expect(c.search("blade of grass", "area").collection.indexOf(p.area) >= 0).to.eql(true); + it('includes the appropriate fallback preset', function() { + expect(c.search('blade of grass', 'point').collection.indexOf(p.point) >= 0).to.eql(true); + expect(c.search('blade of grass', 'area').collection.indexOf(p.area) >= 0).to.eql(true); }); - it("excludes presets with searchable: false", function() { + it('excludes presets with searchable: false', function() { var excluded = iD.presets.Preset('excluded', { tags: {}, geometry: [], searchable: false }), collection = iD.presets.Collection([excluded, p.point]); - expect(collection.search("excluded", "point").collection).not.to.include(excluded); + expect(collection.search('excluded', 'point').collection).not.to.include(excluded); }); }); }); diff --git a/test/spec/presets/preset.js b/test/spec/presets/preset.js index f42d44f8f..99fb7f77f 100644 --- a/test/spec/presets/preset.js +++ b/test/spec/presets/preset.js @@ -1,116 +1,117 @@ +/* globals context: true */ describe('iD.presets.Preset', function() { - it("has optional fields", function() { + it('has optional fields', function() { var preset = iD.presets.Preset('test', {}); expect(preset.fields).to.eql([]); }); describe('#matchGeometry', function() { - it("returns false if it doesn't match", function() { + it('returns false if it doesn\'t match', function() { var preset = iD.presets.Preset('test', {geometry: ['line']}); expect(preset.matchGeometry('point')).to.equal(false); }); - it("returns true if it does match", function() { + it('returns true if it does match', function() { var preset = iD.presets.Preset('test', {geometry: ['point', 'line']}); expect(preset.matchGeometry('point')).to.equal(true); }); }); describe('#matchScore', function() { - it("returns -1 if preset does not match tags", function() { + it('returns -1 if preset does not match tags', function() { var preset = iD.presets.Preset('test', {tags: {foo: 'bar'}}), entity = iD.Way({tags: {highway: 'motorway'}}); expect(preset.matchScore(entity)).to.equal(-1); }); - it("returns the value of the matchScore property when matched", function() { + it('returns the value of the matchScore property when matched', function() { var preset = iD.presets.Preset('test', {tags: {highway: 'motorway'}, matchScore: 0.2}), entity = iD.Way({tags: {highway: 'motorway'}}); expect(preset.matchScore(entity)).to.equal(0.2); }); - it("defaults to the number of matched tags", function() { + it('defaults to the number of matched tags', function() { var preset = iD.presets.Preset('test', {tags: {highway: 'residential'}}), entity = iD.Way({tags: {highway: 'residential'}}); expect(preset.matchScore(entity)).to.equal(1); - var preset = iD.presets.Preset('test', {tags: {highway: 'service', service: 'alley'}}), - entity = iD.Way({tags: {highway: 'service', service: 'alley'}}); + preset = iD.presets.Preset('test', {tags: {highway: 'service', service: 'alley'}}); + entity = iD.Way({tags: {highway: 'service', service: 'alley'}}); expect(preset.matchScore(entity)).to.equal(2); }); - it("counts * as a match for any value with score 0.5", function() { + it('counts * as a match for any value with score 0.5', function() { var preset = iD.presets.Preset('test', {tags: {building: '*'}}), entity = iD.Way({tags: {building: 'yep'}}); expect(preset.matchScore(entity)).to.equal(0.5); }); }); - describe("isFallback", function() { - it("returns true if preset has no tags", function() { - var preset = iD.presets.Preset("point", {tags: {}}); + describe('isFallback', function() { + it('returns true if preset has no tags', function() { + var preset = iD.presets.Preset('point', {tags: {}}); expect(preset.isFallback()).to.equal(true); }); - it("returns true if preset has a single 'area' tag", function() { - var preset = iD.presets.Preset("area", {tags: {area: 'yes'}}); + it('returns true if preset has a single \'area\' tag', function() { + var preset = iD.presets.Preset('area', {tags: {area: 'yes'}}); expect(preset.isFallback()).to.equal(true); }); - it("returns false if preset has a single non-'area' tag", function() { - var preset = iD.presets.Preset("building", {tags: {building: 'yes'}}); + it('returns false if preset has a single non-\'area\' tag', function() { + var preset = iD.presets.Preset('building', {tags: {building: 'yes'}}); expect(preset.isFallback()).to.equal(false); }); - it("returns false if preset has multiple tags", function() { - var preset = iD.presets.Preset("building", {tags: {area: 'yes', building: 'yes'}}); + it('returns false if preset has multiple tags', function() { + var preset = iD.presets.Preset('building', {tags: {area: 'yes', building: 'yes'}}); expect(preset.isFallback()).to.equal(false); }); }); describe('#applyTags', function() { - it("adds match tags", function() { + it('adds match tags', function() { var preset = iD.presets.Preset('test', {tags: {highway: 'residential'}}); expect(preset.applyTags({}, 'line')).to.eql({highway: 'residential'}); }); - it("adds wildcard tags with value 'yes'", function() { + it('adds wildcard tags with value \'yes\'', function() { var preset = iD.presets.Preset('test', {tags: {building: '*'}}); expect(preset.applyTags({}, 'area')).to.eql({building: 'yes'}); }); - it("prefers to add tags of addTags property", function() { + it('prefers to add tags of addTags property', function() { var preset = iD.presets.Preset('test', {tags: {building: '*'}, addTags: {building: 'ok'}}); expect(preset.applyTags({}, 'area')).to.eql({building: 'ok'}); }); - it("adds default tags of fields with matching geometry", function() { + it('adds default tags of fields with matching geometry', function() { var field = iD.presets.Field('field', {key: 'building', geometry: 'area', default: 'yes'}), preset = iD.presets.Preset('test', {fields: ['field']}, {field: field}); expect(preset.applyTags({}, 'area')).to.eql({area: 'yes', building: 'yes'}); }); - it("adds no default tags of fields with non-matching geometry", function() { + it('adds no default tags of fields with non-matching geometry', function() { var field = iD.presets.Field('field', {key: 'building', geometry: 'area', default: 'yes'}), preset = iD.presets.Preset('test', {fields: ['field']}, {field: field}); expect(preset.applyTags({}, 'point')).to.eql({}); }); - context("for a preset with no tag in areaKeys", function() { + context('for a preset with no tag in areaKeys', function() { var preset = iD.presets.Preset('test', {geometry: ['line', 'area'], tags: {name: 'testname', highway: 'pedestrian'}}); - it("doesn't add area=yes to non-areas", function() { + it('doesn\'t add area=yes to non-areas', function() { expect(preset.applyTags({}, 'line')).to.eql({name: 'testname', highway: 'pedestrian'}); }); - it("adds area=yes to areas", function() { + it('adds area=yes to areas', function() { expect(preset.applyTags({}, 'area')).to.eql({name: 'testname', highway: 'pedestrian', area: 'yes'}); }); }); - context("for a preset with a tag in areaKeys", function() { + context('for a preset with a tag in areaKeys', function() { var preset = iD.presets.Preset('test', {geometry: ['area'], tags: {name: 'testname', natural: 'water'}}); - it("doesn't add area=yes", function() { + it('doesn\'t add area=yes', function() { expect(preset.applyTags({}, 'area')).to.eql({name: 'testname', natural: 'water'}); }); });