mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-05 14:38:05 +02:00
Multiselect control over disconnection (#1220)
This commit is contained in:
@@ -35,6 +35,20 @@ describe("iD.actions.Disconnect", function () {
|
||||
|
||||
expect(iD.actions.Disconnect('b').disabled(graph)).not.to.be.ok;
|
||||
});
|
||||
|
||||
it("returns falsy for an intersection of two ways with parent way specified", function () {
|
||||
var graph = iD.Graph({
|
||||
'a': iD.Node({id: 'a'}),
|
||||
'b': iD.Node({id: 'b'}),
|
||||
'c': iD.Node({id: 'c'}),
|
||||
'd': iD.Node({id: 'c'}),
|
||||
'*': iD.Node({id: '*'}),
|
||||
'-': iD.Way({id: '-', nodes: ['a', '*', 'b']}),
|
||||
'|': iD.Way({id: '|', nodes: ['*', 'd']})
|
||||
});
|
||||
|
||||
expect(iD.actions.Disconnect('*', ['|']).disabled(graph)).not.to.be.ok;
|
||||
});
|
||||
});
|
||||
|
||||
it("replaces the node with a new node in all but the first way", function () {
|
||||
@@ -42,7 +56,7 @@ describe("iD.actions.Disconnect", function () {
|
||||
// a ---- b ---- c
|
||||
// |
|
||||
// d
|
||||
// Split at b.
|
||||
// Disconnect at b.
|
||||
//
|
||||
// Expected result:
|
||||
// a ---- b ---- c
|
||||
@@ -60,18 +74,47 @@ describe("iD.actions.Disconnect", function () {
|
||||
'|': iD.Way({id: '|', nodes: ['d', 'b']})
|
||||
});
|
||||
|
||||
graph = iD.actions.Disconnect('b', 'e')(graph);
|
||||
graph = iD.actions.Disconnect('b', undefined, 'e')(graph);
|
||||
|
||||
expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c']);
|
||||
expect(graph.entity('|').nodes).to.eql(['d', 'e']);
|
||||
});
|
||||
|
||||
it("replaces the node with a new node in the specified ways", function () {
|
||||
// Situation:
|
||||
// a ---- b ==== c
|
||||
// |
|
||||
// d
|
||||
// Disconnect - at b.
|
||||
//
|
||||
// Expected result:
|
||||
// a ---- e b ==== c
|
||||
// |
|
||||
// d
|
||||
//
|
||||
var graph = iD.Graph({
|
||||
'a': iD.Node({id: 'a'}),
|
||||
'b': iD.Node({id: 'b'}),
|
||||
'c': iD.Node({id: 'c'}),
|
||||
'd': iD.Node({id: 'd'}),
|
||||
'-': iD.Way({id: '-', nodes: ['a', 'b']}),
|
||||
'=': iD.Way({id: '=', nodes: ['b', 'c']}),
|
||||
'|': iD.Way({id: '|', nodes: ['d', 'b']})
|
||||
});
|
||||
|
||||
graph = iD.actions.Disconnect('b', ['-'], 'e')(graph);
|
||||
|
||||
expect(graph.entity('-').nodes).to.eql(['a', 'e']);
|
||||
expect(graph.entity('=').nodes).to.eql(['b', 'c']);
|
||||
expect(graph.entity('|').nodes).to.eql(['d', 'b']);
|
||||
});
|
||||
|
||||
it("replaces later occurrences in a self-intersecting way", function() {
|
||||
// Situtation:
|
||||
// a ---- b
|
||||
// \_ |
|
||||
// \__ c
|
||||
// Split at a
|
||||
// Disconnect at a
|
||||
//
|
||||
// Expected result:
|
||||
// a ---- b ---- c ---- d
|
||||
@@ -81,7 +124,7 @@ describe("iD.actions.Disconnect", function () {
|
||||
'c': iD.Node({id: 'c'}),
|
||||
'w': iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'a']})
|
||||
});
|
||||
graph = iD.actions.Disconnect('a', 'd')(graph);
|
||||
graph = iD.actions.Disconnect('a', undefined, 'd')(graph);
|
||||
expect(graph.entity('w').nodes).to.eql(['a', 'b', 'c', 'd']);
|
||||
});
|
||||
|
||||
@@ -97,7 +140,7 @@ describe("iD.actions.Disconnect", function () {
|
||||
'|': iD.Way({id: '|', nodes: ['d', 'b']})
|
||||
});
|
||||
|
||||
graph = iD.actions.Disconnect('b', 'e')(graph);
|
||||
graph = iD.actions.Disconnect('b', undefined, 'e')(graph);
|
||||
|
||||
// Immutable loc => should be shared by identity.
|
||||
expect(graph.entity('b').loc).to.equal(loc);
|
||||
|
||||
Reference in New Issue
Block a user