Update tests for faux click events in more places.

This commit is contained in:
Tom MacWright
2013-02-06 15:47:16 -05:00
parent b11e50048e
commit fbe3a41d57
3 changed files with 21 additions and 11 deletions

View File

@@ -137,7 +137,7 @@
iD.debug = true;
mocha.setup({
ui: 'bdd',
globals: ['__onresize.tail-size']
globals: ['__onresize.tail-size', '__onmousemove.zoom', '__onmouseup.zoom', '__onclick.draw']
});
var expect = chai.expect;
</script>

View File

@@ -29,21 +29,31 @@ describe("iD.behavior.Select", function() {
container.remove();
});
specify("click on entity selects the entity", function() {
happen.click(context.surface().select('.' + a.id).node());
expect(context.selection()).to.eql([a.id]);
specify("click on entity selects the entity", function(done) {
happen.mousedown(context.surface().select('.' + a.id).node());
window.setTimeout(function() {
expect(context.selection()).to.eql([a.id]);
done();
}, 600);
});
specify("click on empty space clears the selection", function() {
specify("click on empty space clears the selection", function(done) {
context.enter(iD.modes.Select(context, [a.id]));
happen.click(context.surface().node());
expect(context.selection()).to.eql([]);
happen.mousedown(context.surface().node());
window.setTimeout(function() {
expect(context.selection()).to.eql([]);
done();
}, 600);
});
specify("shift-click on entity adds the entity to the selection", function() {
specify("shift-click on entity adds the entity to the selection", function(done) {
context.enter(iD.modes.Select(context, [a.id]));
happen.click(context.surface().select('.' + b.id).node(), {shiftKey: true});
expect(context.selection()).to.eql([a.id, b.id]);
happen.mousedown(context.surface().select('.' + b.id).node(), {shiftKey: true});
window.setTimeout(function() {
expect(context.selection()).to.eql([a.id, b.id]);
done();
}, 600);
});
specify("shift-click on empty space leaves the selection unchanged", function() {

View File

@@ -17,13 +17,13 @@ describe("iD.modes.AddPoint", function() {
describe("clicking the map", function () {
it("adds a node", function() {
happen.mousedown(context.surface().node(), {});
happen.mouseup(window, {});
happen.click(window, {});
expect(context.changes().created).to.have.length(1);
});
it("selects the node", function() {
happen.mousedown(context.surface().node(), {});
happen.mouseup(window, {});
happen.click(window, {});
expect(context.mode().id).to.equal('select');
expect(context.mode().selection()).to.eql([context.changes().created[0].id]);
});