Skip to content

Commit

Permalink
spec Horizontal line for #2027 (#2028)
Browse files Browse the repository at this point in the history
  • Loading branch information
deyihu authored Jul 21, 2023
1 parent 0746bb5 commit 5467a19
Showing 1 changed file with 69 additions and 44 deletions.
113 changes: 69 additions & 44 deletions test/geometry/event/GeometryEventSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ describe('Geometry.Events', function () {
var spy2 = sinon.spy();
map.on('click', spy2);
happen.mousedown(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).to.be.ok();
expect(spy2.called).to.be.ok();
Expand All @@ -57,8 +57,8 @@ describe('Geometry.Events', function () {
var spy = sinon.spy();
map.on('click', spy);
happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(circleClicked).to.be.ok();
expect(spy.called).not.to.be.ok();
Expand All @@ -73,8 +73,8 @@ describe('Geometry.Events', function () {
expect(param.type).to.be.eql('mousemove');
circle.off('mousemove', onMouseMove);
happen.mousemove(eventContainer, {
'clientX':point.x + 100,
'clientY':point.y + 100
'clientX': point.x + 100,
'clientY': point.y + 100
});
}
circle.on('mousemove', onMouseMove);
Expand All @@ -84,8 +84,8 @@ describe('Geometry.Events', function () {
});

happen.mousemove(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
});

Expand All @@ -110,13 +110,13 @@ describe('Geometry.Events', function () {
circle.on('mouseover', onMouseOver);
circle.on('mouseenter', onMouseOver);
happen.mousemove(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
setTimeout(function () {
happen.mousemove(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
}, 300);

Expand All @@ -131,14 +131,14 @@ describe('Geometry.Events', function () {
circle.on('click', spy);

happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).to.be.ok();
spy.reset();
happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).to.be.ok();
});
Expand All @@ -152,13 +152,13 @@ describe('Geometry.Events', function () {
circle.on('click', spy);

happen.mousedown(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
setTimeout(function () {
happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).not.to.be.ok();
done();
Expand All @@ -174,17 +174,17 @@ describe('Geometry.Events', function () {
circle.on('click', spy);

happen.once(eventContainer, {
'type' : 'touchstart',
'touches' : [{
'clientX':point.x,
'clientY':point.y
'type': 'touchstart',
'touches': [{
'clientX': point.x,
'clientY': point.y
}]
});
happen.once(eventContainer, {
'type' : 'touchend',
'touches' : [{
'clientX':point.x,
'clientY':point.y
'type': 'touchend',
'touches': [{
'clientX': point.x,
'clientY': point.y
}]
});
expect(spy.called).to.be.ok();
Expand All @@ -199,14 +199,14 @@ describe('Geometry.Events', function () {
circle.once('click', spy);

happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).to.be.ok();
spy.reset();
happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).not.to.be.ok();
});
Expand All @@ -221,8 +221,8 @@ describe('Geometry.Events', function () {
circle.on('click', spy);

happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).not.to.be.ok();
});
Expand All @@ -231,8 +231,8 @@ describe('Geometry.Events', function () {
var circle = new maptalks.Marker(map.getCenter(), {
'symbol': {
'markerType': 'circle',
'markerWidth': {stops: [[18, 0], [20, 30]]},
'markerHeight': {stops: [[18, 0], [20, 30]]},
'markerWidth': { stops: [[18, 0], [20, 30]] },
'markerHeight': { stops: [[18, 0], [20, 30]] },
}
});
circle.addTo(layer);
Expand All @@ -242,8 +242,8 @@ describe('Geometry.Events', function () {
circle.on('click', spy);

happen.click(eventContainer, {
'clientX':point.x + 2,
'clientY':point.y
'clientX': point.x + 2,
'clientY': point.y
});
expect(spy.called).not.to.be.ok();
});
Expand All @@ -252,8 +252,8 @@ describe('Geometry.Events', function () {
var circle = new maptalks.Marker(map.getCenter(), {
'symbol': {
'markerType': 'circle',
'markerWidth': {stops: [[10, 0], [20, 30]]},
'markerHeight': {stops: [[10, 0], [20, 30]]},
'markerWidth': { stops: [[10, 0], [20, 30]] },
'markerHeight': { stops: [[10, 0], [20, 30]] },
}
});
circle.addTo(layer);
Expand All @@ -263,9 +263,34 @@ describe('Geometry.Events', function () {
circle.on('click', spy);

happen.click(eventContainer, {
'clientX':point.x + 1,
'clientY':point.y
'clientX': point.x + 1,
'clientY': point.y
});
expect(spy.called).to.be.ok();
});

it('#2027 Horizontal line', function () {
var center = map.getCenter();
var c1 = center.add(1, 0);
var line = new maptalks.LineString([center, c1]);
line.addTo(layer);
var domPosition = GET_PAGE_POSITION(container);
var point = map.coordinateToContainerPoint(center).add(domPosition);
var spy = sinon.spy();
line.on('click', spy);

happen.click(eventContainer, {
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).to.be.ok();
spy.reset();
happen.click(eventContainer, {
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).to.be.ok();
});


});

0 comments on commit 5467a19

Please sign in to comment.