From 2b13de1e3fdd762ed4cb19433d4b59f80e06eac9 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Fri, 5 Apr 2013 12:30:36 -0400 Subject: [PATCH] fix and add tests --- test/spec/behavior/hover.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/spec/behavior/hover.js b/test/spec/behavior/hover.js index 070a552b1..0d6d94aaf 100644 --- a/test/spec/behavior/hover.js +++ b/test/spec/behavior/hover.js @@ -33,15 +33,28 @@ describe("iD.behavior.Hover", function() { describe("mouseover", function () { it("adds the .hover class to all elements to which the same datum is bound", function () { container.selectAll('span') - .data(['a', 'b', 'a', 'b']) - .enter().append('span').attr('class', Object); + .data([{id: 'a'}, {id: 'b'}, {id: 'a'}, {id: 'b'}]) + .enter().append('span').attr('class', function(d) { return d.id; }); container.call(iD.behavior.Hover()); container.selectAll('.a').trigger('mouseover'); + expect(container.selectAll('.a.hover')[0]).to.have.length(2); expect(container.selectAll('.b.hover')[0]).to.have.length(0); }); + + it("adds the .hover class to all members of a relation", function() { + container.selectAll('span') + .data([{id: 'a', type: 'relation', members: [{id: 'b'}]}, {id: 'b'}]) + .enter().append('span').attr('class', function(d) { return d.id; }); + + container.call(iD.behavior.Hover()); + container.selectAll('.a').trigger('mouseover'); + + expect(container.selectAll('.a.hover')[0]).to.have.length(1); + expect(container.selectAll('.b.hover')[0]).to.have.length(1); + }); }); describe("mouseout", function () {