Fix code tests

This commit is contained in:
Quincy Morgan
2020-05-28 11:45:49 -04:00
parent 79ceb96758
commit 2264e4a6d7
2 changed files with 6 additions and 11 deletions

View File

@@ -94,7 +94,7 @@ export function behaviorHover(context) {
function pointerover() {
// ignore mouse hovers with buttons pressed unless dragging
if (!context.mode().id.includes('drag') &&
if (context.mode().id.indexOf('drag') === -1 &&
(!d3_event.pointerType || d3_event.pointerType === 'mouse') &&
d3_event.buttons) return;

View File

@@ -30,7 +30,7 @@ describe('iD.behaviorHover', function() {
});
});
describe('mouseover', function () {
describe('mouseover and mouseout', 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'});
@@ -45,6 +45,9 @@ describe('iD.behaviorHover', function() {
expect(_container.selectAll('.a.hover').nodes()).to.have.length(2);
expect(_container.selectAll('.b.hover').nodes()).to.have.length(0);
iD.utilTriggerEvent(_container.selectAll('.a'), 'mouseout');
expect(_container.selectAll('.hover').nodes()).to.have.length(0);
});
it('adds the .hover class to all members of a relation', function() {
@@ -61,16 +64,8 @@ describe('iD.behaviorHover', function() {
expect(_container.selectAll('.a.hover').nodes()).to.have.length(1);
expect(_container.selectAll('.b.hover').nodes()).to.have.length(1);
});
});
describe('mouseout', function () {
it('removes the .hover class from all elements', function () {
_container.append('span').attr('class', 'hover');
_container.call(iD.behaviorHover(_context));
iD.utilTriggerEvent(_container.selectAll('.hover'), 'mouseout');
iD.utilTriggerEvent(_container.selectAll('.a'), 'mouseout');
expect(_container.selectAll('.hover').nodes()).to.have.length(0);
});
});