mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 13:38:26 +02:00
Add new test cases
This commit is contained in:
+3
-1
@@ -86,6 +86,9 @@
|
||||
<script src='spec/modes/add_point.js'></script>
|
||||
<script src='spec/modes/add_note.js'></script>
|
||||
|
||||
<script src='spec/operations/detach_node.js'></script>
|
||||
<script src='spec/operations/straighten.js'></script>
|
||||
|
||||
<script src='spec/osm/changeset.js'></script>
|
||||
<script src='spec/osm/entity.js'></script>
|
||||
<script src='spec/osm/intersection.js'></script>
|
||||
@@ -158,7 +161,6 @@
|
||||
<script src='spec/validations/tag_suggests_area.js'></script>
|
||||
<script src='spec/validations/unknown_road.js'></script>
|
||||
|
||||
<script src='spec/operations/detach_node.js'></script>
|
||||
<script>
|
||||
window.mocha.run();
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
describe('iD.operationStraighten', function () {
|
||||
var fakeContext;
|
||||
var graph;
|
||||
|
||||
// Set up the fake context
|
||||
fakeContext = {};
|
||||
fakeContext.graph = function () { return graph; };
|
||||
fakeContext.hasHiddenConnections = function () { return false; };
|
||||
|
||||
describe('#available', function () {
|
||||
beforeEach(function () {
|
||||
// w1 - way with 2 nodes
|
||||
// w2 - way with 3 nodes connected to w1
|
||||
// w3 - way with 3 nodes connected to w2
|
||||
// w4 - way with 3 nodes not connected to other ways
|
||||
graph = iD.coreGraph([
|
||||
iD.osmNode({ id: 'n1', type: 'node' }),
|
||||
iD.osmNode({ id: 'n2', type: 'node' }),
|
||||
iD.osmNode({ id: 'n3', type: 'node' }),
|
||||
iD.osmNode({ id: 'n4', type: 'node' }),
|
||||
iD.osmNode({ id: 'n5', type: 'node' }),
|
||||
iD.osmNode({ id: 'n6', type: 'node' }),
|
||||
iD.osmNode({ id: 'n7', type: 'node' }),
|
||||
iD.osmNode({ id: 'n8', type: 'node' }),
|
||||
iD.osmNode({ id: 'n9', type: 'node' }),
|
||||
iD.osmWay({ id: 'w1', nodes: ['n1', 'n2'] }),
|
||||
iD.osmWay({ id: 'w2', nodes: ['n2', 'n3', 'n4'] }),
|
||||
iD.osmWay({ id: 'w3', nodes: ['n4', 'n5', 'n6'] }),
|
||||
iD.osmWay({ id: 'w4', nodes: ['n7', 'n8', 'n9'] })
|
||||
]);
|
||||
});
|
||||
|
||||
it('is not available for no selected ids', function () {
|
||||
var result = iD.operationStraighten([], fakeContext.graph()).available();
|
||||
expect(result).to.be.not.ok;
|
||||
});
|
||||
|
||||
it('is not available for way with only 2 nodes', function () {
|
||||
var result = iD.operationStraighten(['w1'], fakeContext.graph()).available();
|
||||
expect(result).to.be.not.ok;
|
||||
});
|
||||
|
||||
it('is not available for unknown selected id', function () {
|
||||
var result = iD.operationStraighten(['w0'], fakeContext.graph()).available();
|
||||
expect(result).to.be.not.ok;
|
||||
});
|
||||
|
||||
it('is not available for non-continuous ways', function () {
|
||||
var result = iD.operationStraighten(['w3', 'w4'], fakeContext.graph()).available();
|
||||
expect(result).to.be.not.ok;
|
||||
});
|
||||
|
||||
it('is available for selected way with more than 2 nodes', function () {
|
||||
var result = iD.operationStraighten(['w2'], fakeContext.graph()).available();
|
||||
expect(result).to.be.ok;
|
||||
});
|
||||
|
||||
it('is available for selected, ordered, continuous ways', function () {
|
||||
var result = iD.operationStraighten(['w1', 'w2', 'w3'], fakeContext.graph()).available();
|
||||
expect(result).to.be.ok;
|
||||
});
|
||||
|
||||
it('is available for selected, un-ordered, continuous ways', function () {
|
||||
var result = iD.operationStraighten(['w1', 'w3', 'w2'], fakeContext.graph()).available();
|
||||
expect(result).to.be.ok;
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user