"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spec/suites/dom/DomEvent.DoubleTapSpec.js" between
Leaflet-1.8.0.tar.gz and Leaflet-1.9.0.tar.gz

About: Leaflet is a JavaScript library for mobile-friendly interactive maps.

DomEvent.DoubleTapSpec.js  (Leaflet-1.8.0):DomEvent.DoubleTapSpec.js  (Leaflet-1.9.0)
describe('DomEvent.DoubleTapSpec.js', function () { describe('DomEvent.DoubleTapSpec.js', function () {
var el, clock, spy; var container, clock, spy;
beforeEach(function () { beforeEach(function () {
el = document.createElement('div'); container = createContainer();
document.body.appendChild(el);
clock = sinon.useFakeTimers(); clock = sinon.useFakeTimers();
clock.tick(1000); clock.tick(1000);
spy = sinon.spy(); spy = sinon.spy();
L.DomEvent.on(el, 'dblclick', spy); L.DomEvent.on(container, 'dblclick', spy);
}); });
afterEach(function () { afterEach(function () {
clock.restore(); clock.restore();
document.body.removeChild(el); removeMapContainer(null, container);
}); });
it('fires synthetic dblclick after two clicks with delay<200', function ( ) { it('fires synthetic dblclick after two clicks with delay<200', function ( ) {
happen.click(el, {detail: 1}); happen.click(container, {detail: 1});
clock.tick(100); clock.tick(100);
happen.click(el, {detail: 1}); happen.click(container, {detail: 1});
expect(spy.called).to.be.ok(); expect(spy.called).to.be.ok();
expect(spy.calledOnce).to.be.ok(); expect(spy.calledOnce).to.be.ok();
expect(spy.lastCall.args[0]._simulated).to.be.ok(); expect(spy.lastCall.args[0]._simulated).to.be.ok();
}); });
it('does not fire dblclick when delay>200', function () { it('does not fire dblclick when delay>200', function () {
happen.click(el, {detail: 1}); happen.click(container, {detail: 1});
clock.tick(300); clock.tick(300);
happen.click(el, {detail: 1}); happen.click(container, {detail: 1});
expect(spy.notCalled).to.be.ok(); expect(spy.notCalled).to.be.ok();
}); });
it('does not fire dblclick when detail !== 1', function () { it('does not fire dblclick when detail !== 1', function () {
happen.click(el, {detail: 0}); // like in IE happen.click(container, {detail: 0}); // like in IE
clock.tick(100); clock.tick(100);
happen.click(el, {detail: 0}); happen.click(container, {detail: 0});
clock.tick(100); clock.tick(100);
expect(spy.notCalled).to.be.ok(); expect(spy.notCalled).to.be.ok();
}); });
it('does not fire dblclick after removeListener', function () { it('does not fire dblclick after removeListener', function () {
L.DomEvent.off(el, 'dblclick', spy); L.DomEvent.off(container, 'dblclick', spy);
happen.click(el, {detail: 1}); happen.click(container, {detail: 1});
clock.tick(100); clock.tick(100);
happen.click(el, {detail: 1}); happen.click(container, {detail: 1});
clock.tick(100); clock.tick(100);
expect(spy.notCalled).to.be.ok(); expect(spy.notCalled).to.be.ok();
}); });
it('does not conflict with native dblclick', function () { it('does not conflict with native dblclick', function () {
happen.click(el, {detail: 1}); happen.click(container, {detail: 1});
clock.tick(100); clock.tick(100);
happen.click(el, {detail: 2}); // native dblclick expected happen.click(container, {detail: 2}); // native dblclick expected
happen.dblclick(el); happen.dblclick(container);
expect(spy.called).to.be.ok(); expect(spy.called).to.be.ok();
expect(spy.calledOnce).to.be.ok(); expect(spy.calledOnce).to.be.ok();
expect(spy.lastCall.args[0]._simulated).not.to.be.ok(); expect(spy.lastCall.args[0]._simulated).not.to.be.ok();
}); });
it('synthetic dblclick event has expected properties', function () { it('synthetic dblclick event has expected properties', function () {
var click = { var click = {
detail: 1, detail: 1,
clientX: 2, clientX: 2,
clientY: 3, clientY: 3,
screenX: 4, screenX: 4,
screenY: 5 screenY: 5
}; };
happen.click(el, click); happen.click(container, click);
clock.tick(100); clock.tick(100);
happen.click(el, click); happen.click(container, click);
var event = spy.lastCall.args[0]; var event = spy.lastCall.args[0];
var expectedProps = L.extend(click, { var expectedProps = L.extend(click, {
type: 'dblclick', type: 'dblclick',
// bubbles: true, // not important, as we do not actua lly dispatch the event // bubbles: true, // not important, as we do not actua lly dispatch the event
// cancelable: true, // // cancelable: true, //
detail: 2, detail: 2,
target: el target: container
}); });
for (var prop in expectedProps) { for (var prop in expectedProps) {
expect(event[prop]).to.be(expectedProps[prop]); expect(event[prop]).to.be(expectedProps[prop]);
} }
expect(event.isTrusted).not.to.be.ok(); expect(event.isTrusted).not.to.be.ok();
}); });
it('respects disableClickPropagation', function () { it('respects disableClickPropagation', function () {
var spyMap = sinon.spy(); var spyMap = sinon.spy();
var map = L.map(el).setView([51.505, -0.09], 13); var map = L.map(container).setView([51.505, -0.09], 13);
map.on('dblclick', spyMap); map.on('dblclick', spyMap);
var spyCtrl = sinon.spy(); var spyCtrl = sinon.spy();
var ctrl = L.DomUtil.create('div'); var ctrl = L.DomUtil.create('div');
L.DomEvent.disableClickPropagation(ctrl); L.DomEvent.disableClickPropagation(ctrl);
var MyControl = L.Control.extend({ var MyControl = L.Control.extend({
onAdd: function () { onAdd: function () {
return ctrl; return ctrl;
} }
}); });
map.addControl(new MyControl()); map.addControl(new MyControl());
L.DomEvent.on(ctrl, 'dblclick', spyCtrl); L.DomEvent.on(ctrl, 'dblclick', spyCtrl);
happen.click(ctrl, {detail: 1}); happen.click(ctrl, {detail: 1});
clock.tick(100); clock.tick(100);
happen.click(ctrl, {detail: 1}); happen.click(ctrl, {detail: 1});
expect(spyCtrl.called).to.be.ok(); expect(spyCtrl.called).to.be.ok();
expect(spyMap.notCalled).to.be.ok(); expect(spyMap.notCalled).to.be.ok();
}); });
it('doesn\'t fire double-click while clicking on a label with `for` attri
bute', function () {
var spyMap = sinon.spy();
var map = L.map(container).setView([51.505, -0.09], 13);
map.on('dblclick', spyMap);
var div;
var MyControl = L.Control.extend({
onAdd: function () {
div = L.DomUtil.create('div');
div.innerHTML = '<input type="checkbox" id="input
">' +
'<label for="input" style="background: #f
fffff; width: 100px; height: 100px;display: block;">Click Me</label>';
return div;
}
});
map.addControl(new MyControl());
// click on the label
happen.click(div.children[1], {detail: 1});
clock.tick(100);
expect(spyMap.notCalled).to.be.ok();
map.remove();
});
}); });
 End of changes. 20 change blocks. 
21 lines changed or deleted 45 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)