Add unit tests for click event
This commit is contained in:
@@ -4,6 +4,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
|||||||
describe('#emulateClick_', function() {
|
describe('#emulateClick_', function() {
|
||||||
var clock;
|
var clock;
|
||||||
var handler;
|
var handler;
|
||||||
|
var clickSpy;
|
||||||
var singleclickSpy;
|
var singleclickSpy;
|
||||||
var dblclickSpy;
|
var dblclickSpy;
|
||||||
var target;
|
var target;
|
||||||
@@ -15,6 +16,9 @@ describe('ol.MapBrowserEventHandler', function() {
|
|||||||
target: target
|
target: target
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
clickSpy = sinon.spy();
|
||||||
|
goog.events.listen(handler, 'click', clickSpy);
|
||||||
|
|
||||||
singleclickSpy = sinon.spy();
|
singleclickSpy = sinon.spy();
|
||||||
goog.events.listen(handler, 'singleclick', singleclickSpy);
|
goog.events.listen(handler, 'singleclick', singleclickSpy);
|
||||||
|
|
||||||
@@ -28,6 +32,17 @@ describe('ol.MapBrowserEventHandler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('emulates click', function() {
|
it('emulates click', function() {
|
||||||
|
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown',
|
||||||
|
new goog.events.BrowserEvent({
|
||||||
|
type: 'mousedown',
|
||||||
|
target: target,
|
||||||
|
clientX: 0,
|
||||||
|
clientY: 0
|
||||||
|
})));
|
||||||
|
expect(clickSpy.called).to.be.ok();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('emulates singleclick', function() {
|
||||||
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown',
|
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown',
|
||||||
new goog.events.BrowserEvent({
|
new goog.events.BrowserEvent({
|
||||||
type: 'mousedown',
|
type: 'mousedown',
|
||||||
|
|||||||
Reference in New Issue
Block a user