mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 13:59:27 +02:00
additional test tweaks
ref #remote-presets
This commit is contained in:
@@ -8,12 +8,7 @@ import _isString from 'lodash-es/isString';
|
||||
import _map from 'lodash-es/map';
|
||||
|
||||
import { dispatch as d3_dispatch } from 'd3-dispatch';
|
||||
|
||||
import {
|
||||
json as d3_json,
|
||||
text as d3_text
|
||||
} from 'd3-request';
|
||||
|
||||
import { json as d3_json } from 'd3-request';
|
||||
import { select as d3_select } from 'd3-selection';
|
||||
|
||||
import {
|
||||
@@ -461,9 +456,11 @@ export function coreContext() {
|
||||
|
||||
if (utilExternalValidationRules()) {
|
||||
var validationsUrl = utilStringQs(window.location.hash).validations;
|
||||
d3_text(validationsUrl, function (err, mapcss) {
|
||||
d3_json(validationsUrl, function (err, mapcssConfigs) {
|
||||
if (err) return;
|
||||
var validations = _map(mapcss, function(mapcss) { return utilMapCSSRule(mapcss, context.presets().areaKeys()); });
|
||||
var validations = _map(mapcssConfigs, function(mapcssConfig) {
|
||||
return utilMapCSSRule(mapcssConfig, context.presets().areaKeys());
|
||||
});
|
||||
context.validationRules = function() { return validations; };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,8 +59,11 @@ export function utilMapCSSRule(selector, areaKeys) {
|
||||
.map(function(key) { return ruleChecks[key]; });
|
||||
|
||||
},
|
||||
selector: function() {
|
||||
return selector;
|
||||
},
|
||||
buildTagMap: function() {
|
||||
var selectorKeys = Object.keys(selector);
|
||||
var selector = this.selector(), selectorKeys = Object.keys(selector);
|
||||
var tagMap = _reduce(selectorKeys, function (expectedTags, key) {
|
||||
var values;
|
||||
if (/regex/gi.test(key)) {
|
||||
@@ -146,7 +149,7 @@ export function utilMapCSSRule(selector, areaKeys) {
|
||||
if (entity.type === 'node' || entity.type === 'relation') {
|
||||
return selector.geometry === entity.type;
|
||||
} else if (entity.type === 'way') {
|
||||
return this.inferGeometry(areaKeys) === entity.geometry(graph);
|
||||
return this.inferGeometry() === entity.geometry(graph);
|
||||
}
|
||||
},
|
||||
findWarnings: function (entity, graph, warnings) {
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('iD.utilMapCSSRule', function() {
|
||||
var rules = selectors.map(function(s) { return iD.utilMapCSSRule(s, areaKeys); });
|
||||
it ('turns selector object in mapcssRule', function () {
|
||||
var ruleKeys = [
|
||||
'ruleChecks', 'type','buildChecks', 'buildTagMap', 'matches',
|
||||
'ruleChecks', 'type','buildChecks', 'selector', 'buildTagMap', 'matches',
|
||||
'areaKeys', 'inferGeometry', 'geometryMatches','findWarnings'
|
||||
];
|
||||
rules.forEach(function(rule) {
|
||||
@@ -110,7 +110,13 @@ describe('iD.utilMapCSSRule', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('areaKeys', function() {
|
||||
describe('#selector', function() {
|
||||
it('returns selector used to construct rule', function() {
|
||||
var rule = iD.utilMapCSSRule(selectors[1], areaKeys);
|
||||
expect(rule.selector()).to.eql(selectors[1]);
|
||||
});
|
||||
});
|
||||
describe('#areaKeys', function() {
|
||||
it('returns areaKeys used to construct rule', function() {
|
||||
var rule = iD.utilMapCSSRule(selectors[0], areaKeys);
|
||||
expect(rule.areaKeys()).to.eql(areaKeys);
|
||||
|
||||
Reference in New Issue
Block a user