From ba08ba6109127228044bdbf22f0821b3fd4d3c27 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 13 May 2013 13:04:13 -0700 Subject: [PATCH] Fix tests --- test/spec/behavior/hover.js | 37 ++++++++++++++++++++++++------------- test/spec/renderer/map.js | 3 +++ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/test/spec/behavior/hover.js b/test/spec/behavior/hover.js index cdb2cc01d..b20205a7c 100644 --- a/test/spec/behavior/hover.js +++ b/test/spec/behavior/hover.js @@ -9,20 +9,7 @@ describe("iD.behavior.Hover", function() { container.remove(); }); - describe("#on", function () { - it("adds the .behavior-hover class to the selection", function () { - container.call(iD.behavior.Hover()); - expect(container).to.be.classed('behavior-hover') - }); - }); - describe("#off", function () { - it("removes the .behavior-hover class from the selection", function () { - container.classed('behavior-hover', true); - container.call(iD.behavior.Hover().off); - expect(container).not.to.be.classed('behavior-hover') - }); - it("removes the .hover class from all elements", function () { container.append('span').attr('class', 'hover'); container.call(iD.behavior.Hover().off); @@ -69,4 +56,28 @@ describe("iD.behavior.Hover", function() { expect(container.selectAll('.hover')[0]).to.have.length(0); }); }); + + describe("alt keydown", function () { + it("replaces the .hover class with .hover-suppressed", function () { + container.append('span').attr('class', 'hover'); + + container.call(iD.behavior.Hover().altDisables(true)); + happen.keydown(document, {keyCode: 18}); + + expect(container.selectAll('.hover')[0]).to.have.length(0); + expect(container.selectAll('.hover-suppressed')[0]).to.have.length(1); + }); + }); + + describe("alt keyup", function () { + it("replaces the .hover-suppressed class with .hover", function () { + container.append('span').attr('class', 'hover-suppressed'); + + container.call(iD.behavior.Hover().altDisables(true)); + happen.keyup(document, {keyCode: 18}); + + expect(container.selectAll('.hover')[0]).to.have.length(1); + expect(container.selectAll('.hover-suppressed')[0]).to.have.length(0); + }); + }); }); diff --git a/test/spec/renderer/map.js b/test/spec/renderer/map.js index 84966003d..4f2d965d7 100644 --- a/test/spec/renderer/map.js +++ b/test/spec/renderer/map.js @@ -202,6 +202,8 @@ describe('iD.Map', function() { specify('hovered ways use draw-connect-line cursor in draw modes', function() { behavior.attr('class', 'behavior-hover'); + line.classed('hover', true); + area.classed('hover', true); mode.attr('class', 'mode-draw-line'); expect(cursor(line)).to.match(/cursor-draw-connect-line/); expect(cursor(area)).to.match(/cursor-draw-connect-line/); @@ -221,6 +223,7 @@ describe('iD.Map', function() { specify('hovered vertices use draw-connect-vertex cursor in draw modes', function() { behavior.attr('class', 'behavior-hover'); + vertex.classed('hover', true); mode.attr('class', 'mode-draw-line'); expect(cursor(vertex)).to.match(/cursor-draw-connect-vertex/); mode.attr('class', 'mode-draw-area');