Remaining files and add eslint test/spec to package.json

This commit is contained in:
Kushan Joshi
2016-06-15 18:36:48 +05:30
parent 3f3b287d62
commit 6d580f66c2
6 changed files with 30 additions and 28 deletions
+2 -3
View File
@@ -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",
+2 -1
View File
@@ -8,7 +8,8 @@
"afterEach": true,
"mocha": true,
"sinon": true,
"happen": true
"happen": true,
"before": true,
},
"rules": {
"no-unused-expressions": 0
+2 -2
View File
@@ -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() {
+16 -16
View File
@@ -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');
+3 -1
View File
@@ -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;
+5 -5
View File
@@ -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')))