Require init() call before coreContext starts doing things

(closes #7304)
This commit is contained in:
Bryan Housel
2020-01-29 19:27:12 -05:00
parent fb4d658860
commit e19bcb77d5
45 changed files with 182 additions and 178 deletions
+1
View File
@@ -34,6 +34,7 @@
} else {
var context = iD.coreContext();
context.init();
// disable boundaries (unless we have an explicit disable_features list)
var q = iD.utilStringQs(window.location.hash.substring(1));
+1
View File
@@ -34,6 +34,7 @@
} else {
var context = iD.coreContext().assetPath('dist/');
window.context = window.id = context; // for debugging
context.init();
// disable boundaries (unless we have an explicit disable_features list)
var q = iD.utilStringQs(window.location.hash.substring(1));
+92 -89
View File
@@ -472,103 +472,106 @@ export function coreContext() {
/* Init */
context.init = () => {
context.projection = geoRawMercator();
context.curtainProjection = geoRawMercator();
context.projection = geoRawMercator();
context.curtainProjection = geoRawMercator();
_locale = utilDetect().locale;
if (_locale && !dataLocales.hasOwnProperty(_locale)) {
_locale = _locale.split('-')[0];
}
_data = coreData(context);
_history = coreHistory(context);
_validator = coreValidator(context);
context.graph = _history.graph;
context.changes = _history.changes;
context.intersects = _history.intersects;
context.pauseChangeDispatch = _history.pauseChangeDispatch;
context.resumeChangeDispatch = _history.resumeChangeDispatch;
// Debounce save, since it's a synchronous localStorage write,
// and history changes can happen frequently (e.g. when dragging).
context.debouncedSave = _debounce(context.save, 350);
function withDebouncedSave(fn) {
return function() {
const result = fn.apply(_history, arguments);
context.debouncedSave();
return result;
};
}
context.perform = withDebouncedSave(_history.perform);
context.replace = withDebouncedSave(_history.replace);
context.pop = withDebouncedSave(_history.pop);
context.overwrite = withDebouncedSave(_history.overwrite);
context.undo = withDebouncedSave(_history.undo);
context.redo = withDebouncedSave(_history.redo);
_ui = uiInit(context);
_connection = services.osm;
_background = rendererBackground(context);
_features = rendererFeatures(context);
_photos = rendererPhotos(context);
_presets = presetIndex(context);
const hash = utilStringQs(window.location.hash);
if (services.maprules && hash.maprules) {
d3_json(hash.maprules)
.then(mapcss => {
services.maprules.init();
mapcss.forEach(mapcssSelector => services.maprules.addRule(mapcssSelector));
})
.catch(() => { /* ignore */ });
}
_map = rendererMap(context);
context.mouse = _map.mouse;
context.extent = _map.extent;
context.pan = _map.pan;
context.zoomIn = _map.zoomIn;
context.zoomOut = _map.zoomOut;
context.zoomInFurther = _map.zoomInFurther;
context.zoomOutFurther = _map.zoomOutFurther;
context.redrawEnable = _map.redrawEnable;
Object.values(services).forEach(service => {
if (service && typeof service.init === 'function') {
service.init(context);
_locale = utilDetect().locale;
if (_locale && !dataLocales.hasOwnProperty(_locale)) {
_locale = _locale.split('-')[0];
}
});
_validator.init();
_background.init();
_features.init();
_photos.init();
_data = coreData(context);
_history = coreHistory(context);
_validator = coreValidator(context);
let presetsParameter = hash.presets;
if (presetsParameter && presetsParameter.indexOf('://') !== -1) {
// a URL of external presets file
_presets.fromExternal(external, (externalPresets) => {
context.presets = () => externalPresets; // default + external presets...
context.graph = _history.graph;
context.changes = _history.changes;
context.intersects = _history.intersects;
context.pauseChangeDispatch = _history.pauseChangeDispatch;
context.resumeChangeDispatch = _history.resumeChangeDispatch;
// Debounce save, since it's a synchronous localStorage write,
// and history changes can happen frequently (e.g. when dragging).
context.debouncedSave = _debounce(context.save, 350);
function withDebouncedSave(fn) {
return function() {
const result = fn.apply(_history, arguments);
context.debouncedSave();
return result;
};
}
context.perform = withDebouncedSave(_history.perform);
context.replace = withDebouncedSave(_history.replace);
context.pop = withDebouncedSave(_history.pop);
context.overwrite = withDebouncedSave(_history.overwrite);
context.undo = withDebouncedSave(_history.undo);
context.redo = withDebouncedSave(_history.redo);
_ui = uiInit(context);
_connection = services.osm;
_background = rendererBackground(context);
_features = rendererFeatures(context);
_photos = rendererPhotos(context);
_presets = presetIndex(context);
const hash = utilStringQs(window.location.hash);
if (services.maprules && hash.maprules) {
d3_json(hash.maprules)
.then(mapcss => {
services.maprules.init();
mapcss.forEach(mapcssSelector => services.maprules.addRule(mapcssSelector));
})
.catch(() => { /* ignore */ });
}
_map = rendererMap(context);
context.mouse = _map.mouse;
context.extent = _map.extent;
context.pan = _map.pan;
context.zoomIn = _map.zoomIn;
context.zoomOut = _map.zoomOut;
context.zoomInFurther = _map.zoomInFurther;
context.zoomOutFurther = _map.zoomOutFurther;
context.redrawEnable = _map.redrawEnable;
Object.values(services).forEach(service => {
if (service && typeof service.init === 'function') {
service.init(context);
}
});
_validator.init();
_background.init();
_features.init();
_photos.init();
let presetsParameter = hash.presets;
if (presetsParameter && presetsParameter.indexOf('://') !== -1) {
// a URL of external presets file
_presets.fromExternal(external, (externalPresets) => {
context.presets = () => externalPresets; // default + external presets...
osmSetAreaKeys(_presets.areaKeys());
osmSetPointTags(_presets.pointTags());
osmSetVertexTags(_presets.vertexTags());
});
} else {
let addablePresetIDs;
if (presetsParameter) {
// a list of allowed preset IDs
addablePresetIDs = presetsParameter.split(',');
}
_presets.init(addablePresetIDs);
osmSetAreaKeys(_presets.areaKeys());
osmSetPointTags(_presets.pointTags());
osmSetVertexTags(_presets.vertexTags());
});
} else {
let addablePresetIDs;
if (presetsParameter) {
// a list of allowed preset IDs
addablePresetIDs = presetsParameter.split(',');
}
_presets.init(addablePresetIDs);
osmSetAreaKeys(_presets.areaKeys());
osmSetPointTags(_presets.pointTags());
osmSetVertexTags(_presets.vertexTags());
}
return context;
};
return context;
}
+1 -1
View File
@@ -1,7 +1,7 @@
describe('iD.actionSplit', function () {
beforeEach(function () {
iD.areaKeys = iD.coreContext().presets().areaKeys();
iD.areaKeys = iD.coreContext().init().presets().areaKeys();
});
+1 -1
View File
@@ -4,7 +4,7 @@ describe('iD.behaviorHash', function () {
var hash, context;
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
var container = d3.select(document.createElement('div'));
context.container(container);
container.call(context.map());
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.behaviorLasso', function () {
var context, lasso;
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map());
+1 -1
View File
@@ -3,7 +3,7 @@ describe('iD.behaviorSelect', function() {
beforeEach(function() {
container = d3.select('body').append('div');
context = iD.coreContext().container(container);
context = iD.coreContext().container(container).init();
a = iD.osmNode({loc: [0, 0]});
b = iD.osmNode({loc: [0, 0]});
+5 -5
View File
@@ -5,7 +5,7 @@ describe('iD.coreContext', function() {
describe('#assetPath', function() {
it('sets and gets assetPath', function() {
var context = iD.coreContext();
var context = iD.coreContext().init();
expect(context.assetPath()).to.eql('');
context.assetPath('iD/');
@@ -15,7 +15,7 @@ describe('iD.coreContext', function() {
describe('#assetMap', function() {
it('sets and gets assetMap', function() {
var context = iD.coreContext();
var context = iD.coreContext().init();
expect(context.assetMap()).to.eql({});
context.assetMap(assets);
@@ -26,7 +26,7 @@ describe('iD.coreContext', function() {
describe('#asset', function() {
var context;
beforeEach(function() {
context = iD.coreContext().assetPath('iD/').assetMap(assets);
context = iD.coreContext().assetPath('iD/').assetMap(assets).init();
});
it('ignores absolute urls', function() {
@@ -44,7 +44,7 @@ describe('iD.coreContext', function() {
describe('#imagePath', function() {
var context;
beforeEach(function() {
context = iD.coreContext().assetPath('iD/').assetMap(assets);
context = iD.coreContext().assetPath('iD/').assetMap(assets).init();
});
it('looks first in assetMap', function() {
@@ -57,7 +57,7 @@ describe('iD.coreContext', function() {
describe('#debug', function() {
it('sets and gets debug flags', function() {
var context = iD.coreContext();
var context = iD.coreContext().init();
var flags = {
tile: false,
collision: false,
+1 -1
View File
@@ -10,7 +10,7 @@ describe('iD.coreData', function() {
});
beforeEach(function() {
_context = iD.coreContext();
_context = iD.coreContext().init();
});
+1 -1
View File
@@ -8,7 +8,7 @@ describe('iD.coreHistory', function () {
};
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
history = context.history();
spy = sinon.spy();
// clear lock
+17 -17
View File
@@ -1,8 +1,8 @@
describe('iD.Tree', function() {
describe('iD.coreTree', function() {
describe('#rebase', function() {
it('adds entities to the tree', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]});
graph.rebase([node], [graph]);
@@ -13,7 +13,7 @@ describe('iD.Tree', function() {
it('is idempotent', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -28,7 +28,7 @@ describe('iD.Tree', function() {
it('does not insert if entity has a modified version', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
node_ = node.update({loc: [10, 10]}),
g = graph.replace(node_);
@@ -44,7 +44,7 @@ describe('iD.Tree', function() {
it('does not error on self-referencing relations', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
relation = iD.osmRelation();
@@ -59,7 +59,7 @@ describe('iD.Tree', function() {
it('adjusts entities that are force-rebased', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]});
graph.rebase([node], [graph]);
@@ -76,7 +76,7 @@ describe('iD.Tree', function() {
describe('#intersects', function() {
it('includes entities within extent, excludes those without', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
n1 = iD.osmNode({loc: [1, 1]}),
n2 = iD.osmNode({loc: [3, 3]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -87,7 +87,7 @@ describe('iD.Tree', function() {
it('includes intersecting relations after incomplete members are loaded', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
n1 = iD.osmNode({id: 'n1', loc: [0, 0]}),
n2 = iD.osmNode({id: 'n2', loc: [1, 1]}),
relation = iD.osmRelation({id: 'r', members: [{id: 'n1'}, {id: 'n2'}]}),
@@ -105,7 +105,7 @@ describe('iD.Tree', function() {
// This happens when local storage includes a changed way but not its nodes.
it('includes intersecting ways after missing nodes are loaded', function() {
var base = iD.coreGraph(),
tree = iD.Tree(base),
tree = iD.coreTree(base),
node = iD.osmNode({id: 'n', loc: [0.5, 0.5]}),
way = iD.osmWay({nodes: ['n']}),
graph = base.replace(way),
@@ -120,7 +120,7 @@ describe('iD.Tree', function() {
it('adjusts parent ways when a member node is moved', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
way = iD.osmWay({nodes: ['n']}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -134,7 +134,7 @@ describe('iD.Tree', function() {
it('adjusts parent relations when a member node is moved', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
relation = iD.osmRelation({members: [{type: 'node', id: 'n'}]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -148,7 +148,7 @@ describe('iD.Tree', function() {
it('adjusts parent relations of parent ways when a member node is moved', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
way = iD.osmWay({id: 'w', nodes: ['n']}),
relation = iD.osmRelation({members: [{type: 'multipolygon', id: 'w'}]}),
@@ -163,7 +163,7 @@ describe('iD.Tree', function() {
it('adjusts parent ways when a member node is removed', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
n1 = iD.osmNode({id: 'n1', loc: [1, 1]}),
n2 = iD.osmNode({id: 'n2', loc: [3, 3]}),
way = iD.osmWay({nodes: ['n1', 'n2']}),
@@ -179,7 +179,7 @@ describe('iD.Tree', function() {
it('don\'t include parent way multiple times when multiple child nodes are moved', function() {
// checks against the following regression: https://github.com/openstreetmap/iD/issues/1978
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
n1 = iD.osmNode({id: 'n1', loc: [1, 1]}),
n2 = iD.osmNode({id: 'n2', loc: [3, 3]}),
way = iD.osmWay({id: 'w1', nodes: ['n1', 'n2']}),
@@ -195,7 +195,7 @@ describe('iD.Tree', function() {
it('doesn\'t include removed entities', function() {
var graph = iD.coreGraph(),
tree = iD.Tree(graph),
tree = iD.coreTree(graph),
node = iD.osmNode({loc: [1, 1]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -208,7 +208,7 @@ describe('iD.Tree', function() {
it('doesn\'t include removed entities after rebase', function() {
var base = iD.coreGraph(),
tree = iD.Tree(base),
tree = iD.coreTree(base),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -222,7 +222,7 @@ describe('iD.Tree', function() {
it('handles recursive relations', function() {
var base = iD.coreGraph(),
tree = iD.Tree(base),
tree = iD.coreTree(base),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
r1 = iD.osmRelation({id: 'r1', members: [{id: 'n'}]}),
r2 = iD.osmRelation({id: 'r2', members: [{id: 'r1'}]}),
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.coreValidator', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
function createInvalidWay() {
+2 -2
View File
@@ -11,9 +11,9 @@ describe('iD.modeAddNote', function() {
beforeEach(function() {
var container = d3.select(document.createElement('div'));
context = iD.coreContext()
.container(container);
.container(container)
.init();
context.loadTiles = function () {};
+2 -1
View File
@@ -5,7 +5,8 @@ describe.skip('iD.modeAddPoint', function() {
var container = d3.select(document.createElement('div'));
context = iD.coreContext()
.container(container);
.container(container)
.init();
context.loadTiles = function () {};
+1 -1
View File
@@ -406,7 +406,7 @@ describe('iD.osmWay', function() {
describe('#isArea', function() {
before(function() {
iD.coreContext();
iD.coreContext().init();
});
it('returns false when the way has no tags', function() {
+19 -19
View File
@@ -24,7 +24,7 @@ describe('iD.presetIndex', function () {
it('returns a collection containing presets matching a geometry and tags', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
var way = iD.osmWay({ tags: { highway: 'residential' } });
var graph = iD.coreGraph([way]);
@@ -33,7 +33,7 @@ describe('iD.presetIndex', function () {
it('returns the appropriate fallback preset when no tags match', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
var point = iD.osmNode();
var line = iD.osmWay({ tags: { foo: 'bar' } });
var graph = iD.coreGraph([point, line]);
@@ -44,7 +44,7 @@ describe('iD.presetIndex', function () {
it('matches vertices on a line as points', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
var point = iD.osmNode({ tags: { leisure: 'park' } });
var line = iD.osmWay({ nodes: [point.id], tags: { 'highway': 'residential' } });
var graph = iD.coreGraph([point, line]);
@@ -54,7 +54,7 @@ describe('iD.presetIndex', function () {
it('matches vertices on an addr:interpolation line as points', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
var point = iD.osmNode({ tags: { leisure: 'park' } });
var line = iD.osmWay({ nodes: [point.id], tags: { 'addr:interpolation': 'even' } });
var graph = iD.coreGraph([point, line]);
@@ -79,44 +79,44 @@ describe('iD.presetIndex', function () {
it('whitelists keys for presets with area geometry', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
expect(presets.areaKeys()).to.include.keys('natural');
});
it('blacklists key-values for presets with a line geometry', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
expect(presets.areaKeys().natural).to.include.keys('tree_row');
expect(presets.areaKeys().natural.tree_row).to.be.true;
});
it('blacklists key-values for presets with both area and line geometry', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
expect(presets.areaKeys().leisure).to.include.keys('track');
});
it('does not blacklist key-values for presets with neither area nor line geometry', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
expect(presets.areaKeys().natural).not.to.include.keys('peak');
});
it('does not blacklist generic \'*\' key-values', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
expect(presets.areaKeys().natural).not.to.include.keys('natural');
});
it('ignores keys like \'highway\' that are assumed to be lines', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
expect(presets.areaKeys()).not.to.include.keys('highway');
});
it('ignores suggestion presets', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
expect(presets.areaKeys()).not.to.include.keys('amenity');
});
});
@@ -125,7 +125,7 @@ describe('iD.presetIndex', function () {
it('builds presets from provided', function () {
var surfShop = iD.osmNode({ tags: { amenity: 'shop', 'shop:type': 'surf' } });
var graph = iD.coreGraph([surfShop]);
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
var morePresets = {
presets: {
'amenity/shop/surf': {
@@ -145,7 +145,7 @@ describe('iD.presetIndex', function () {
var firstStreetJetty = iD.osmNode({ tags: { man_made: 'jetty' } });
var entities = [surfShop, firstStreetJetty];
var graph = iD.coreGraph(entities);
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
var morePresets = {
presets: {
'amenity/shop/surf': {
@@ -199,7 +199,7 @@ describe('iD.presetIndex', function () {
it('prefers building to multipolygon', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
var relation = iD.osmRelation({ tags: { type: 'multipolygon', building: 'yes' } });
var graph = iD.coreGraph([relation]);
expect(presets.match(relation, graph).id).to.eql('building');
@@ -207,7 +207,7 @@ describe('iD.presetIndex', function () {
it('prefers building to address', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
var way = iD.osmWay({ tags: { area: 'yes', building: 'yes', 'addr:housenumber': '1234' } });
var graph = iD.coreGraph([way]);
expect(presets.match(way, graph).id).to.eql('building');
@@ -215,7 +215,7 @@ describe('iD.presetIndex', function () {
it('prefers pedestrian to area', function () {
iD.data.presets = testPresets;
var presets = iD.coreContext().presets();
var presets = iD.coreContext().init().presets();
var way = iD.osmWay({ tags: { area: 'yes', highway: 'pedestrian' } });
var graph = iD.coreGraph([way]);
expect(presets.match(way, graph).id).to.eql('highway/pedestrian_area');
@@ -258,13 +258,13 @@ describe('iD.presetIndex', function () {
var url = 'https://fakemaprules.io/fake.json';
// no exernal presets yet
expect(iD.coreContext().presets().match(surfShop, graph).id).to.eql('point');
expect(iD.coreContext().init().presets().match(surfShop, graph).id).to.eql('point');
// reset graph...
graph = iD.coreGraph([surfShop]);
// add the validations query param...
iD.coreContext().presets().fromExternal(url, function (externalPresets) {
iD.coreContext().init().presets().fromExternal(url, function (externalPresets) {
expect(externalPresets.match(surfShop, graph).id).to.eql('8bc64d6d');
});
@@ -277,7 +277,7 @@ describe('iD.presetIndex', function () {
it('makes only the external presets initially addable', function () {
var url = 'https://fakemaprules.io/fake.json';
iD.coreContext().presets().fromExternal(url, function(externalPresets) {
iD.coreContext().init().presets().fromExternal(url, function(externalPresets) {
var external = externalPresets.collection.reduce(function(presets, preset) {
if (!preset.hasOwnProperty('members') && preset.addable()) {
presets.push(preset.id);
+1 -1
View File
@@ -3,7 +3,7 @@ describe('iD.rendererFeatures', function() {
var context, features;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map());
+1 -1
View File
@@ -3,7 +3,7 @@ describe('iD.Map', function() {
beforeEach(function() {
content = d3.select('body').append('div');
context = iD.coreContext();
context = iD.coreContext().init();
map = context.map();
content.call(map);
});
+7 -9
View File
@@ -2,7 +2,7 @@ describe('iD.TileLayer', function() {
var context, d, c;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
d = d3.select(document.createElement('div'));
c = iD.TileLayer(context).projection(d3.geoMercator());
});
@@ -11,14 +11,12 @@ describe('iD.TileLayer', function() {
d.remove();
});
describe('iD.TileLayer', function() {
it('is instantiated', function() {
expect(c).to.be.ok;
});
it('is instantiated', function() {
expect(c).to.be.ok;
});
it('#dimensions', function() {
expect(c.dimensions([100, 100])).to.equal(c);
expect(c.dimensions()).to.eql([100,100]);
});
it('#dimensions', function() {
expect(c.dimensions([100, 100])).to.equal(c);
expect(c.dimensions()).to.eql([100,100]);
});
});
+1 -1
View File
@@ -12,7 +12,7 @@ describe('iD.serviceMapillary', function() {
});
beforeEach(function() {
context = iD.coreContext().assetPath('../dist/');
context = iD.coreContext().assetPath('../dist/').init();
context.projection
.scale(iD.geoZoomToScale(14))
.translate([-116508, 0]) // 10,0
+1 -1
View File
@@ -11,7 +11,7 @@ describe('iD.serviceOpenstreetcam', function() {
});
beforeEach(function() {
context = iD.coreContext().assetPath('../dist/');
context = iD.coreContext().assetPath('../dist/').init();
context.projection
.scale(iD.geoZoomToScale(14))
.translate([-116508, 0]) // 10,0
+1 -1
View File
@@ -27,7 +27,7 @@ describe('iD.serviceOsm', function () {
beforeEach(function () {
serverFetch = window.fakeFetch().create(); // unauthenticated calls use d3-fetch
serverXHR = sinon.fakeServer.create(); // authenticated calls use XHR via osm-auth
context = iD.coreContext();
context = iD.coreContext().init();
connection = context.connection();
connection.switch({ urlroot: 'http://www.openstreetmap.org' });
connection.reset();
+1 -1
View File
@@ -11,7 +11,7 @@ describe('iD.serviceStreetside', function() {
});
beforeEach(function() {
context = iD.coreContext().assetPath('../dist/');
context = iD.coreContext().assetPath('../dist/').init();
context.projection
.scale(iD.geoZoomToScale(14))
.translate([-116508, 0]) // 10,0
+1 -1
View File
@@ -9,7 +9,7 @@ describe('iD.svgAreas', function () {
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([0, 0], 17));
+1 -1
View File
@@ -81,7 +81,7 @@ describe('iD.svgData', function () {
}
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([-74.389286, 40.1502754], 17));
+1 -1
View File
@@ -6,7 +6,7 @@ describe('iD.svgLayers', function () {
.clipExtent([[0, 0], [Infinity, Infinity]]);
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
container = d3.select(document.createElement('div'));
});
+1 -1
View File
@@ -9,7 +9,7 @@ describe('iD.svgLines', function () {
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([0, 0], 17));
+1 -1
View File
@@ -9,7 +9,7 @@ describe('iD.svgMidpoints', function () {
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
context.enter({
id: 'select',
enter: function() { },
+1 -1
View File
@@ -6,7 +6,7 @@ describe('iD.svgPoints', function () {
.clipExtent([[0, 0], [Infinity, Infinity]]);
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([0, 0], 17));
+1 -1
View File
@@ -8,7 +8,7 @@ describe('iD.svgVertices', function () {
beforeEach(function () {
context = iD.coreContext();
context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([0, 0], 17));
+1 -1
View File
@@ -66,7 +66,7 @@ describe('uiCombobox', function() {
beforeEach(function() {
body = d3.select('body');
container = body.append('div').attr('class', 'id-container');
context = iD.coreContext().container(container);
context = iD.coreContext().container(container).init();
content = container.append('div');
input = content.append('input');
combobox = iD.uiCombobox(context);
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.uiFieldAccess', function() {
var context, selection, field;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
selection = d3.select(document.createElement('div'));
field = iD.presetField('access', {
keys: ['access', 'foot', 'motor_vehicle', 'bicycle', 'horse'],
+1 -1
View File
@@ -15,7 +15,7 @@ describe('iD.uiFieldLocalized', function() {
});
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
selection = d3.select(document.createElement('div'));
field = iD.presetField('name', { key: 'name', type: 'localized' });
field.locked = function() { return false; };
+1 -1
View File
@@ -51,7 +51,7 @@ describe('iD.uiFieldWikipedia', function() {
beforeEach(function() {
entity = iD.osmNode({id: 'n12345'});
context = iD.coreContext();
context = iD.coreContext().init();
context.history().merge([entity]);
selection = d3.select(document.createElement('div'));
field = iD.presetField('wikipedia', {
+1 -1
View File
@@ -16,7 +16,7 @@ describe('iD.uiRawTagEditor', function() {
beforeEach(function () {
entity = iD.osmNode({id: 'n12345'});
context = iD.coreContext();
context = iD.coreContext().init();
context.history().merge([entity]);
render({highway: 'residential'});
});
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.validations.almost_junction', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
function horizontalVertialCloserThanThd() {
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.validations.crossing_ways', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
function createWaysWithOneCrossingPoint(tags1, tags2) {
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.validations.disconnected_way', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
function createWay(tags) {
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.validations.incompatible_source', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
function createWay(tags) {
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.validations.mismatched_geometry', function () {
var context;
beforeEach(function() {
context = iD.Context();
context = iD.coreContext().init();
});
function createPoint(tags) {
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.validations.missing_role', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
function createWay(tags) {
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.validations.missing_tag', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
function createWay(tags) {
+1 -1
View File
@@ -13,7 +13,7 @@ describe('iD.validations.outdated_tags', function () {
});
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.validations.private_data', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
function createWay(tags) {
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.validations.suspicious_name', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
context = iD.coreContext().init();
});
function createWay(tags) {