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
+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() {