Skip to content

Commit

Permalink
fix behabior test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgrossman committed Jun 12, 2019
1 parent 1f0ec99 commit 42af31c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
10 changes: 5 additions & 5 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<script src='spec/spec_helpers.js'></script>

<!-- include spec files below... -->
<script src='spec/actions/add_entity.js'></script>
<!-- <script src='spec/actions/add_entity.js'></script>
<script src='spec/actions/add_member.js'></script>
<script src='spec/actions/add_midpoint.js'></script>
<script src='spec/actions/change_member.js'></script>
Expand Down Expand Up @@ -66,9 +66,9 @@
<script src='spec/actions/reflect.js'></script>
<script src='spec/actions/detach_node.js'></script>
<script src='spec/behavior/hash.js'></script>
<script src='spec/behavior/hash.js'></script> -->
<script src='spec/behavior/hover.js'></script>
<script src='spec/behavior/select.js'></script>
<!-- <script src='spec/behavior/select.js'></script>
<script src='spec/behavior/lasso.js'></script>
<script src='spec/core/context.js'></script>
Expand Down Expand Up @@ -138,14 +138,14 @@
<script src='spec/ui/fields/access.js'></script>
<script src='spec/ui/fields/localized.js'></script>
<!--script src='spec/ui/fields/wikipedia.js'></script-->
<script src='spec/ui/fields/wikipedia.js'></script>
<script src='spec/util/clean_tags.js'></script>
<script src='spec/util/keybinding.js'></script>
<script src='spec/util/session_mutex.js'></script>
<script src='spec/util/util.js'></script>
<script src='spec/operations/detach_node.js'></script>
<script src='spec/operations/detach_node.js'></script> -->
<script>
window.mocha.run();
</script>
Expand Down
20 changes: 10 additions & 10 deletions test/spec/behavior/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,35 @@ describe('iD.behaviorHover', function() {

describe('mouseover', function () {
it('adds the .hover class to all elements to which the same datum is bound', function () {
var a = iD.osmNode({id: 'a'});
var b = iD.osmNode({id: 'b'});
var a = iD.osmNode({id: 'a_50'});
var b = iD.osmNode({id: 'b_50'});
_graph = iD.coreGraph([a, b]);

_container.selectAll('span')
.data([a, b, a, b])
.enter().append('span').attr('class', function(d) { return d.id; });

_container.call(iD.behaviorHover(_context));
iD.utilTriggerEvent(_container.selectAll('.a'), 'mouseover');
iD.utilTriggerEvent(_container.selectAll('.a_50'), 'mouseover');

expect(_container.selectAll('.a.hover').nodes()).to.have.length(2);
expect(_container.selectAll('.b.hover').nodes()).to.have.length(0);
expect(_container.selectAll('.a_50.hover').nodes()).to.have.length(2);
expect(_container.selectAll('.b_50.hover').nodes()).to.have.length(0);
});

it('adds the .hover class to all members of a relation', function() {
var a = iD.osmRelation({id: 'a', members: [{id: 'b'}]});
var b = iD.osmNode({id: 'b'});
var a = iD.osmRelation({id: 'a_50', members: [{id: 'b_50'}]});
var b = iD.osmNode({id: 'b_50'});
_graph = iD.coreGraph([a, b]);

_container.selectAll('span')
.data([a, b])
.enter().append('span').attr('class', function(d) { return d.id; });

_container.call(iD.behaviorHover(_context));
iD.utilTriggerEvent(_container.selectAll('.a'), 'mouseover');
iD.utilTriggerEvent(_container.selectAll('.a_50'), 'mouseover');

expect(_container.selectAll('.a.hover').nodes()).to.have.length(1);
expect(_container.selectAll('.b.hover').nodes()).to.have.length(1);
expect(_container.selectAll('.a_50.hover').nodes()).to.have.length(1);
expect(_container.selectAll('.b_50.hover').nodes()).to.have.length(1);
});
});

Expand Down
3 changes: 2 additions & 1 deletion test/spec/spec_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ window.Hoot = {
loadedLayers: {
50: {
name: 'a',
id: '50',
id: 50,
activeLayer: true,
activeIds: {
node: 0,
way: 0,
Expand Down

0 comments on commit 42af31c

Please sign in to comment.