Named exports from ol/events
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js';
|
||||
import ReprojImage from '../../../../src/ol/reproj/Image.js';
|
||||
@@ -21,7 +21,7 @@ describe('ol.rendering.reproj.Image', function() {
|
||||
return source.getImage(extent, resolution, pixelRatio, sourceProj);
|
||||
});
|
||||
if (image.getState() == 0) { // IDLE
|
||||
_ol_events_.listen(image, 'change', function(e) {
|
||||
listen(image, 'change', function(e) {
|
||||
if (image.getState() == 2) { // LOADED
|
||||
expect(imagesRequested).to.be(1);
|
||||
resembleCanvas(image.getImage(), expectedUrl, IMAGE_TOLERANCE, done);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import TileState from '../../../../src/ol/TileState.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
import ReprojTile from '../../../../src/ol/reproj/Tile.js';
|
||||
import XYZ from '../../../../src/ol/source/XYZ.js';
|
||||
@@ -24,7 +24,7 @@ describe('ol.rendering.reproj.Tile', function() {
|
||||
return source.getTile(z, x, y, pixelRatio, sourceProjection);
|
||||
});
|
||||
if (tile.getState() == TileState.IDLE) {
|
||||
_ol_events_.listen(tile, 'change', function(e) {
|
||||
listen(tile, 'change', function(e) {
|
||||
if (tile.getState() == TileState.LOADED) {
|
||||
expect(tilesRequested).to.be(expectedRequests);
|
||||
resembleCanvas(tile.getImage(), expectedUrl, 7.5, done);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import {listen} from '../../../src/ol/events.js';
|
||||
import Collection from '../../../src/ol/Collection.js';
|
||||
import CollectionEventType from '../../../src/ol/CollectionEventType.js';
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('ol.collection', function() {
|
||||
});
|
||||
it('returns the correct new length of the collection', function() {
|
||||
let length;
|
||||
_ol_events_.listen(collection, 'add', function(event) {
|
||||
listen(collection, 'add', function(event) {
|
||||
if (event.element === 'remove_me') {
|
||||
collection.remove(event.element);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ describe('ol.collection', function() {
|
||||
it('fires a remove event', function() {
|
||||
const collection = new Collection([0, 1, 2]);
|
||||
const cb = sinon.spy();
|
||||
_ol_events_.listen(collection, CollectionEventType.REMOVE, cb);
|
||||
listen(collection, CollectionEventType.REMOVE, cb);
|
||||
expect(collection.remove(1)).to.eql(1);
|
||||
expect(cb).to.be.called();
|
||||
expect(cb.lastCall.args[0].element).to.eql(1);
|
||||
@@ -141,10 +141,10 @@ describe('ol.collection', function() {
|
||||
it('does dispatch events', function() {
|
||||
const collection = new Collection(['a', 'b']);
|
||||
let added, removed;
|
||||
_ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
|
||||
listen(collection, CollectionEventType.ADD, function(e) {
|
||||
added = e.element;
|
||||
});
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
collection, CollectionEventType.REMOVE, function(e) {
|
||||
removed = e.element;
|
||||
});
|
||||
@@ -158,7 +158,7 @@ describe('ol.collection', function() {
|
||||
it('does dispatch events', function() {
|
||||
const collection = new Collection(['a']);
|
||||
let removed;
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
collection, CollectionEventType.REMOVE, function(e) {
|
||||
removed = e.element;
|
||||
});
|
||||
@@ -171,7 +171,7 @@ describe('ol.collection', function() {
|
||||
it('does dispatch events', function() {
|
||||
const collection = new Collection([0, 2]);
|
||||
let added;
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
collection, CollectionEventType.ADD, function(e) {
|
||||
added = e.element;
|
||||
});
|
||||
@@ -183,7 +183,7 @@ describe('ol.collection', function() {
|
||||
describe('setAt beyond end', function() {
|
||||
it('triggers events properly', function() {
|
||||
const added = [];
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
collection, CollectionEventType.ADD, function(e) {
|
||||
added.push(e.element);
|
||||
});
|
||||
@@ -204,7 +204,7 @@ describe('ol.collection', function() {
|
||||
beforeEach(function() {
|
||||
collection = new Collection([0, 1, 2]);
|
||||
cb = sinon.spy();
|
||||
_ol_events_.listen(collection, 'change:length', cb);
|
||||
listen(collection, 'change:length', cb);
|
||||
});
|
||||
|
||||
describe('insertAt', function() {
|
||||
@@ -233,7 +233,7 @@ describe('ol.collection', function() {
|
||||
it('triggers add when pushing', function() {
|
||||
const collection = new Collection();
|
||||
let elem;
|
||||
_ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
|
||||
listen(collection, CollectionEventType.ADD, function(e) {
|
||||
elem = e.element;
|
||||
});
|
||||
const length = collection.push(1);
|
||||
@@ -250,8 +250,8 @@ describe('ol.collection', function() {
|
||||
});
|
||||
describe('setAt', function() {
|
||||
it('triggers remove', function() {
|
||||
_ol_events_.listen(collection, CollectionEventType.ADD, cb1);
|
||||
_ol_events_.listen(collection, CollectionEventType.REMOVE, cb2);
|
||||
listen(collection, CollectionEventType.ADD, cb1);
|
||||
listen(collection, CollectionEventType.REMOVE, cb2);
|
||||
collection.setAt(0, 2);
|
||||
expect(cb2.lastCall.args[0].element).to.eql(1);
|
||||
expect(cb1.lastCall.args[0].element).to.eql(2);
|
||||
@@ -259,7 +259,7 @@ describe('ol.collection', function() {
|
||||
});
|
||||
describe('pop', function() {
|
||||
it('triggers remove', function() {
|
||||
_ol_events_.listen(collection, CollectionEventType.REMOVE, cb1);
|
||||
listen(collection, CollectionEventType.REMOVE, cb1);
|
||||
collection.pop();
|
||||
expect(cb1.lastCall.args[0].element).to.eql(1);
|
||||
});
|
||||
@@ -277,7 +277,7 @@ describe('ol.collection', function() {
|
||||
it('fires events', function() {
|
||||
const collection = new Collection();
|
||||
const elems = [];
|
||||
_ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
|
||||
listen(collection, CollectionEventType.ADD, function(e) {
|
||||
elems.push(e.element);
|
||||
});
|
||||
collection.extend([1, 2]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import {listen, listenOnce, bindListener, unlisten, unlistenAll, unlistenByKey, findListener, getListeners} from '../../../src/ol/events.js';
|
||||
import EventTarget from '../../../src/ol/events/EventTarget.js';
|
||||
|
||||
describe('ol.events', function() {
|
||||
@@ -13,13 +13,13 @@ describe('ol.events', function() {
|
||||
};
|
||||
});
|
||||
|
||||
describe('bindListener_()', function() {
|
||||
describe('bindListener()', function() {
|
||||
it('binds a listener and returns a bound listener function', function() {
|
||||
const listenerObj = {
|
||||
listener: sinon.spy(),
|
||||
bindTo: {id: 1}
|
||||
};
|
||||
const boundListener = _ol_events_.bindListener_(listenerObj);
|
||||
const boundListener = bindListener(listenerObj);
|
||||
expect(listenerObj.boundListener).to.equal(boundListener);
|
||||
boundListener();
|
||||
expect(listenerObj.listener.thisValues[0]).to.equal(listenerObj.bindTo);
|
||||
@@ -29,7 +29,7 @@ describe('ol.events', function() {
|
||||
listener: sinon.spy(),
|
||||
target: {id: 1}
|
||||
};
|
||||
const boundListener = _ol_events_.bindListener_(listenerObj);
|
||||
const boundListener = bindListener(listenerObj);
|
||||
expect(listenerObj.boundListener).to.equal(boundListener);
|
||||
boundListener();
|
||||
expect(listenerObj.listener.thisValues[0]).to.equal(listenerObj.target);
|
||||
@@ -42,19 +42,16 @@ describe('ol.events', function() {
|
||||
bindTo: bindTo,
|
||||
callOnce: true
|
||||
};
|
||||
const unlistenSpy = sinon.spy(_ol_events_, 'unlistenByKey'); // eslint-disable-line openlayers-internal/no-missing-requires
|
||||
listenerObj.listener = function() {
|
||||
expect(this).to.equal(bindTo);
|
||||
expect(unlistenSpy.firstCall.args[0]).to.eql(listenerObj);
|
||||
};
|
||||
const boundListener = _ol_events_.bindListener_(listenerObj);
|
||||
const boundListener = bindListener(listenerObj);
|
||||
expect(listenerObj.boundListener).to.equal(boundListener);
|
||||
boundListener();
|
||||
unlistenSpy.restore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('findListener_()', function() {
|
||||
describe('findListener()', function() {
|
||||
let listener, listenerObj, listeners;
|
||||
|
||||
beforeEach(function() {
|
||||
@@ -69,18 +66,18 @@ describe('ol.events', function() {
|
||||
|
||||
it('searches a listener array for a specific listener', function() {
|
||||
const bindTo = {id: 1};
|
||||
let result = _ol_events_.findListener_(listeners, listener);
|
||||
let result = findListener(listeners, listener);
|
||||
expect(result).to.be(listenerObj);
|
||||
result = _ol_events_.findListener_(listeners, listener, bindTo);
|
||||
result = findListener(listeners, listener, bindTo);
|
||||
expect(result).to.be(undefined);
|
||||
listenerObj.bindTo = bindTo;
|
||||
result = _ol_events_.findListener_(listeners, listener);
|
||||
result = findListener(listeners, listener);
|
||||
expect(result).to.be(undefined);
|
||||
result = _ol_events_.findListener_(listeners, listener, bindTo);
|
||||
result = findListener(listeners, listener, bindTo);
|
||||
expect(result).to.be(listenerObj);
|
||||
});
|
||||
it('marks the delete index on a listener object', function() {
|
||||
const result = _ol_events_.findListener_(listeners, listener, undefined, true);
|
||||
const result = findListener(listeners, listener, undefined, true);
|
||||
expect(result).to.be(listenerObj);
|
||||
expect(listenerObj.deleteIndex).to.be(0);
|
||||
});
|
||||
@@ -88,37 +85,37 @@ describe('ol.events', function() {
|
||||
|
||||
describe('getListeners()', function() {
|
||||
it('returns listeners for a target and type', function() {
|
||||
const foo = _ol_events_.listen(target, 'foo', function() {});
|
||||
const bar = _ol_events_.listen(target, 'bar', function() {});
|
||||
expect (_ol_events_.getListeners(target, 'foo')).to.eql([foo]);
|
||||
expect (_ol_events_.getListeners(target, 'bar')).to.eql([bar]);
|
||||
const foo = listen(target, 'foo', function() {});
|
||||
const bar = listen(target, 'bar', function() {});
|
||||
expect (getListeners(target, 'foo')).to.eql([foo]);
|
||||
expect (getListeners(target, 'bar')).to.eql([bar]);
|
||||
});
|
||||
it('returns undefined when no listeners are registered', function() {
|
||||
expect (_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect (getListeners(target, 'foo')).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('listen()', function() {
|
||||
it('calls addEventListener on the target', function() {
|
||||
_ol_events_.listen(target, 'foo', function() {});
|
||||
listen(target, 'foo', function() {});
|
||||
expect(add.callCount).to.be(1);
|
||||
});
|
||||
it('returns a key', function() {
|
||||
const key = _ol_events_.listen(target, 'foo', function() {});
|
||||
const key = listen(target, 'foo', function() {});
|
||||
expect(key).to.be.a(Object);
|
||||
});
|
||||
it('does not add the same listener twice', function() {
|
||||
const listener = function() {};
|
||||
const key1 = _ol_events_.listen(target, 'foo', listener);
|
||||
const key2 = _ol_events_.listen(target, 'foo', listener);
|
||||
const key1 = listen(target, 'foo', listener);
|
||||
const key2 = listen(target, 'foo', listener);
|
||||
expect(key1).to.equal(key2);
|
||||
expect(add.callCount).to.be(1);
|
||||
});
|
||||
it('only treats listeners as same when all args are equal', function() {
|
||||
const listener = function() {};
|
||||
_ol_events_.listen(target, 'foo', listener, {});
|
||||
_ol_events_.listen(target, 'foo', listener, {});
|
||||
_ol_events_.listen(target, 'foo', listener, undefined);
|
||||
listen(target, 'foo', listener, {});
|
||||
listen(target, 'foo', listener, {});
|
||||
listen(target, 'foo', listener, undefined);
|
||||
expect(add.callCount).to.be(3);
|
||||
});
|
||||
});
|
||||
@@ -126,7 +123,7 @@ describe('ol.events', function() {
|
||||
describe('listenOnce()', function() {
|
||||
it('creates a one-off listener', function() {
|
||||
const listener = sinon.spy();
|
||||
const key = _ol_events_.listenOnce(target, 'foo', listener);
|
||||
const key = listenOnce(target, 'foo', listener);
|
||||
expect(add.callCount).to.be(1);
|
||||
expect(key.callOnce).to.be(true);
|
||||
key.boundListener();
|
||||
@@ -135,17 +132,17 @@ describe('ol.events', function() {
|
||||
});
|
||||
it('does not add the same listener twice', function() {
|
||||
const listener = function() {};
|
||||
const key1 = _ol_events_.listenOnce(target, 'foo', listener);
|
||||
const key2 = _ol_events_.listenOnce(target, 'foo', listener);
|
||||
const key1 = listenOnce(target, 'foo', listener);
|
||||
const key2 = listenOnce(target, 'foo', listener);
|
||||
expect(key1).to.equal(key2);
|
||||
expect(add.callCount).to.be(1);
|
||||
expect(key1.callOnce).to.be(true);
|
||||
});
|
||||
it('listen() can turn a one-off listener into a permanent one', function() {
|
||||
const listener = sinon.spy();
|
||||
let key = _ol_events_.listenOnce(target, 'foo', listener);
|
||||
let key = listenOnce(target, 'foo', listener);
|
||||
expect(key.callOnce).to.be(true);
|
||||
key = _ol_events_.listen(target, 'foo', listener);
|
||||
key = listen(target, 'foo', listener);
|
||||
expect(add.callCount).to.be(1);
|
||||
expect(key.callOnce).to.be(false);
|
||||
key.boundListener();
|
||||
@@ -156,42 +153,42 @@ describe('ol.events', function() {
|
||||
describe('unlisten()', function() {
|
||||
it('unregisters previously registered listeners', function() {
|
||||
const listener = function() {};
|
||||
_ol_events_.listen(target, 'foo', listener);
|
||||
_ol_events_.unlisten(target, 'foo', listener);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
listen(target, 'foo', listener);
|
||||
unlisten(target, 'foo', listener);
|
||||
expect(getListeners(target, 'foo')).to.be(undefined);
|
||||
});
|
||||
it('works with multiple types', function() {
|
||||
const listener = function() {};
|
||||
_ol_events_.listen(target, ['foo', 'bar'], listener);
|
||||
_ol_events_.unlisten(target, ['bar', 'foo'], listener);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(_ol_events_.getListeners(target, 'bar')).to.be(undefined);
|
||||
listen(target, ['foo', 'bar'], listener);
|
||||
unlisten(target, ['bar', 'foo'], listener);
|
||||
expect(getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(getListeners(target, 'bar')).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unlistenByKey()', function() {
|
||||
it('unregisters previously registered listeners', function() {
|
||||
const key = _ol_events_.listen(target, 'foo', function() {});
|
||||
_ol_events_.unlistenByKey(key);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
const key = listen(target, 'foo', function() {});
|
||||
unlistenByKey(key);
|
||||
expect(getListeners(target, 'foo')).to.be(undefined);
|
||||
});
|
||||
it('works with multiple types', function() {
|
||||
const key = _ol_events_.listen(target, ['foo', 'bar'], function() {});
|
||||
_ol_events_.unlistenByKey(key);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(_ol_events_.getListeners(target, 'bar')).to.be(undefined);
|
||||
const key = listen(target, ['foo', 'bar'], function() {});
|
||||
unlistenByKey(key);
|
||||
expect(getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(getListeners(target, 'bar')).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unlistenAll()', function() {
|
||||
it('unregisters all listeners registered for a target', function() {
|
||||
const keys = [
|
||||
_ol_events_.listen(target, 'foo', function() {}),
|
||||
_ol_events_.listen(target, 'bar', function() {})
|
||||
listen(target, 'foo', function() {}),
|
||||
listen(target, 'bar', function() {})
|
||||
];
|
||||
_ol_events_.unlistenAll(target);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(_ol_events_.getListeners(target, 'bar')).to.be(undefined);
|
||||
unlistenAll(target);
|
||||
expect(getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(getListeners(target, 'bar')).to.be(undefined);
|
||||
expect('ol_lm' in target).to.be(false);
|
||||
expect(keys).to.eql([{}, {}]);
|
||||
});
|
||||
@@ -201,17 +198,17 @@ describe('ol.events', function() {
|
||||
it('does not register duplicated listeners', function() {
|
||||
const target = new EventTarget();
|
||||
const listener = function() {};
|
||||
const key1 = _ol_events_.listen(target, 'foo', listener);
|
||||
const key1 = listen(target, 'foo', listener);
|
||||
expect(target.getListeners('foo')).to.eql([key1.boundListener]);
|
||||
const key2 = _ol_events_.listen(target, 'foo', listener);
|
||||
const key2 = listen(target, 'foo', listener);
|
||||
expect(key2.boundListener).to.equal(key1.boundListener);
|
||||
expect(target.getListeners('foo')).to.eql([key1.boundListener]);
|
||||
});
|
||||
it('registers multiple listeners if this object is different', function() {
|
||||
const target = new EventTarget();
|
||||
const listener = function() {};
|
||||
const key1 = _ol_events_.listen(target, 'foo', listener, {});
|
||||
const key2 = _ol_events_.listen(target, 'foo', listener, {});
|
||||
const key1 = listen(target, 'foo', listener, {});
|
||||
const key2 = listen(target, 'foo', listener, {});
|
||||
expect(key1.boundListener).to.not.equal(key2.boundListener);
|
||||
expect(target.getListeners('foo')).to.eql(
|
||||
[key1.boundListener, key2.boundListener]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Disposable from '../../../../src/ol/Disposable.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import Event from '../../../../src/ol/events/Event.js';
|
||||
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
||||
|
||||
@@ -154,7 +154,7 @@ describe('ol.events.EventTarget', function() {
|
||||
|
||||
describe('#dispose()', function() {
|
||||
it('cleans up foreign references', function() {
|
||||
_ol_events_.listen(eventTarget, 'foo', spy1, document);
|
||||
listen(eventTarget, 'foo', spy1, document);
|
||||
expect(eventTarget.hasListener('foo')).to.be(true);
|
||||
eventTarget.dispose();
|
||||
expect(eventTarget.hasListener('foo')).to.be(false);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import ImageTile from '../../../src/ol/ImageTile.js';
|
||||
import TileState from '../../../src/ol/TileState.js';
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import {listen, unlistenByKey} from '../../../src/ol/events.js';
|
||||
import EventType from '../../../src/ol/events/EventType.js';
|
||||
import ImageSource from '../../../src/ol/source/Image.js';
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('ol.ImageTile', function() {
|
||||
|
||||
let previousState = tile.getState();
|
||||
|
||||
_ol_events_.listen(tile, EventType.CHANGE, function(event) {
|
||||
listen(tile, EventType.CHANGE, function(event) {
|
||||
const state = tile.getState();
|
||||
if (previousState == TileState.IDLE) {
|
||||
expect(state).to.be(TileState.LOADING);
|
||||
@@ -43,7 +43,7 @@ describe('ol.ImageTile', function() {
|
||||
|
||||
let previousState = tile.getState();
|
||||
|
||||
_ol_events_.listen(tile, EventType.CHANGE, function(event) {
|
||||
listen(tile, EventType.CHANGE, function(event) {
|
||||
const state = tile.getState();
|
||||
if (previousState == TileState.ERROR) {
|
||||
expect(state).to.be(TileState.LOADING);
|
||||
@@ -66,12 +66,12 @@ describe('ol.ImageTile', function() {
|
||||
const tileLoadFunction = ImageSource.defaultImageLoadFunction;
|
||||
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
|
||||
|
||||
const key = _ol_events_.listen(tile, EventType.CHANGE, function(event) {
|
||||
const key = listen(tile, EventType.CHANGE, function(event) {
|
||||
const state = tile.getState();
|
||||
if (state == TileState.ERROR) {
|
||||
expect(state).to.be(TileState.ERROR);
|
||||
expect(tile.image_).to.be.a(HTMLCanvasElement);
|
||||
_ol_events_.unlistenByKey(key);
|
||||
unlistenByKey(key);
|
||||
tile.load();
|
||||
expect(tile.image_).to.be.a(HTMLImageElement);
|
||||
done();
|
||||
|
||||
@@ -3,7 +3,7 @@ import Map from '../../../../src/ol/Map.js';
|
||||
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import View from '../../../../src/ol/View.js';
|
||||
import {equals} from '../../../../src/ol/array.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import _ol_events_condition_ from '../../../../src/ol/events/condition.js';
|
||||
import Circle from '../../../../src/ol/geom/Circle.js';
|
||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||
@@ -205,8 +205,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
const ds = sinon.spy();
|
||||
const de = sinon.spy();
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
listen(draw, 'drawstart', ds);
|
||||
listen(draw, 'drawend', de);
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
simulateEvent('pointerdown', 10, 20);
|
||||
simulateEvent('pointerup', 10, 20);
|
||||
@@ -222,7 +222,7 @@ describe('ol.interaction.Draw', function() {
|
||||
end: 0,
|
||||
addfeature: 0
|
||||
};
|
||||
_ol_events_.listen(draw, 'drawend',
|
||||
listen(draw, 'drawend',
|
||||
function() {
|
||||
expect(receivedEvents.end).to.be(0);
|
||||
expect(receivedEvents.addfeature).to.be(0);
|
||||
@@ -439,8 +439,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
const ds = sinon.spy();
|
||||
const de = sinon.spy();
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
listen(draw, 'drawstart', ds);
|
||||
listen(draw, 'drawend', de);
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -703,8 +703,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
const ds = sinon.spy();
|
||||
const de = sinon.spy();
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
listen(draw, 'drawstart', ds);
|
||||
listen(draw, 'drawend', de);
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -861,8 +861,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
const ds = sinon.spy();
|
||||
const de = sinon.spy();
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
listen(draw, 'drawstart', ds);
|
||||
listen(draw, 'drawend', de);
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -1088,7 +1088,7 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
it('dispatches a drawstart event', function() {
|
||||
const spy = sinon.spy();
|
||||
_ol_events_.listen(draw, 'drawstart', spy);
|
||||
listen(draw, 'drawstart', spy);
|
||||
draw.extend(feature);
|
||||
expect(spy.callCount).to.be(1);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import Feature from '../../../../src/ol/Feature.js';
|
||||
import Map from '../../../../src/ol/Map.js';
|
||||
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import View from '../../../../src/ol/View.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {getListeners} from '../../../../src/ol/events.js';
|
||||
import _ol_events_condition_ from '../../../../src/ol/events/condition.js';
|
||||
import Circle from '../../../../src/ol/geom/Circle.js';
|
||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||
@@ -604,11 +604,11 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
describe('handle feature change', function() {
|
||||
let getListeners;
|
||||
let getModifyListeners;
|
||||
|
||||
beforeEach(function() {
|
||||
getListeners = function(feature, modify) {
|
||||
const listeners = _ol_events_.getListeners(
|
||||
getModifyListeners = function(feature, modify) {
|
||||
const listeners = getListeners(
|
||||
feature, 'change');
|
||||
return listeners.filter(function(listener) {
|
||||
return listener.bindTo === modify;
|
||||
@@ -628,7 +628,7 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
let listeners;
|
||||
|
||||
listeners = getListeners(feature, modify);
|
||||
listeners = getModifyListeners(feature, modify);
|
||||
expect(listeners).to.have.length(1);
|
||||
|
||||
let firstSegmentData;
|
||||
@@ -652,7 +652,7 @@ describe('ol.interaction.Modify', function() {
|
||||
expect(firstSegmentData.segment[0]).to.eql([1, 1]);
|
||||
expect(firstSegmentData.segment[1]).to.eql([1, 1]);
|
||||
|
||||
listeners = getListeners(feature, modify);
|
||||
listeners = getModifyListeners(feature, modify);
|
||||
expect(listeners).to.have.length(1);
|
||||
});
|
||||
|
||||
@@ -665,7 +665,7 @@ describe('ol.interaction.Modify', function() {
|
||||
const feature = features[0];
|
||||
let listeners;
|
||||
|
||||
listeners = getListeners(feature, modify);
|
||||
listeners = getModifyListeners(feature, modify);
|
||||
expect(listeners).to.have.length(1);
|
||||
|
||||
let firstSegmentData;
|
||||
@@ -690,7 +690,7 @@ describe('ol.interaction.Modify', function() {
|
||||
expect(firstSegmentData.segment[0]).to.eql([1, 1]);
|
||||
expect(firstSegmentData.segment[1]).to.eql([10, 20]);
|
||||
|
||||
listeners = getListeners(feature, modify);
|
||||
listeners = getModifyListeners(feature, modify);
|
||||
expect(listeners).to.have.length(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Map from '../../../src/ol/Map.js';
|
||||
import MapBrowserEventHandler from '../../../src/ol/MapBrowserEventHandler.js';
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import {listen} from '../../../src/ol/events.js';
|
||||
import _ol_has_ from '../../../src/ol/has.js';
|
||||
import PointerEvent from '../../../src/ol/pointer/PointerEvent.js';
|
||||
|
||||
@@ -21,13 +21,13 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
}));
|
||||
|
||||
clickSpy = sinon.spy();
|
||||
_ol_events_.listen(handler, 'click', clickSpy);
|
||||
listen(handler, 'click', clickSpy);
|
||||
|
||||
singleclickSpy = sinon.spy();
|
||||
_ol_events_.listen(handler, 'singleclick', singleclickSpy);
|
||||
listen(handler, 'singleclick', singleclickSpy);
|
||||
|
||||
dblclickSpy = sinon.spy();
|
||||
_ol_events_.listen(handler, 'dblclick', dblclickSpy);
|
||||
listen(handler, 'dblclick', dblclickSpy);
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BaseObject from '../../../src/ol/Object.js';
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import {listen} from '../../../src/ol/events.js';
|
||||
|
||||
|
||||
describe('ol.Object', function() {
|
||||
@@ -115,10 +115,10 @@ describe('ol.Object', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
listener1 = sinon.spy();
|
||||
_ol_events_.listen(o, 'change:k', listener1);
|
||||
listen(o, 'change:k', listener1);
|
||||
|
||||
listener2 = sinon.spy();
|
||||
_ol_events_.listen(o, 'propertychange', listener2);
|
||||
listen(o, 'propertychange', listener2);
|
||||
});
|
||||
|
||||
it('dispatches events', function() {
|
||||
@@ -148,10 +148,10 @@ describe('ol.Object', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
listener1 = sinon.spy();
|
||||
_ol_events_.listen(o, 'change:k', listener1);
|
||||
listen(o, 'change:k', listener1);
|
||||
|
||||
listener2 = sinon.spy();
|
||||
_ol_events_.listen(o, 'propertychange', listener2);
|
||||
listen(o, 'propertychange', listener2);
|
||||
});
|
||||
|
||||
it('dispatches events to object', function() {
|
||||
@@ -224,9 +224,9 @@ describe('ol.Object', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
listener1 = sinon.spy();
|
||||
_ol_events_.listen(o, 'change:k', listener1);
|
||||
listen(o, 'change:k', listener1);
|
||||
listener2 = sinon.spy();
|
||||
_ol_events_.listen(o, 'change:K', listener2);
|
||||
listen(o, 'change:K', listener2);
|
||||
});
|
||||
|
||||
it('dispatches the expected event', function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_has_ from '../../../../src/ol/has.js';
|
||||
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.js';
|
||||
@@ -31,7 +31,7 @@ describe('ol.pointer.MouseSource', function() {
|
||||
|
||||
describe('simulated mouse events', function() {
|
||||
it('prevents simulated mouse events', function() {
|
||||
_ol_events_.listen(handler, 'pointerdown', eventSpy);
|
||||
listen(handler, 'pointerdown', eventSpy);
|
||||
|
||||
// simulates that a mouse event is triggered from a touch
|
||||
simulateTouchEvent('touchstart', 10, 20);
|
||||
@@ -42,7 +42,7 @@ describe('ol.pointer.MouseSource', function() {
|
||||
});
|
||||
|
||||
it('dispatches real mouse events', function() {
|
||||
_ol_events_.listen(handler, 'pointerdown', eventSpy);
|
||||
listen(handler, 'pointerdown', eventSpy);
|
||||
|
||||
// the two events are at different positions
|
||||
simulateTouchEvent('touchstart', 10, 20);
|
||||
@@ -55,7 +55,7 @@ describe('ol.pointer.MouseSource', function() {
|
||||
// set the timeout to a lower value, to speed up the tests
|
||||
TouchSource.DEDUP_TIMEOUT = 100;
|
||||
|
||||
_ol_events_.listen(handler, 'pointerdown', eventSpy);
|
||||
listen(handler, 'pointerdown', eventSpy);
|
||||
|
||||
// first simulate a touch event, then a mouse event
|
||||
// at the same position after a timeout
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_has_ from '../../../../src/ol/has.js';
|
||||
import MouseSource from '../../../../src/ol/pointer/MouseSource.js';
|
||||
@@ -46,7 +46,7 @@ describe('ol.pointer.PointerEventHandler', function() {
|
||||
|
||||
describe('pointer down', function() {
|
||||
it('fires pointerdown events', function() {
|
||||
_ol_events_.listen(handler, 'pointerdown', eventSpy);
|
||||
listen(handler, 'pointerdown', eventSpy);
|
||||
simulateEvent('mousedown', 0, 0);
|
||||
expect(eventSpy.calledOnce).to.be.ok();
|
||||
|
||||
@@ -60,7 +60,7 @@ describe('ol.pointer.PointerEventHandler', function() {
|
||||
|
||||
describe('pointer up', function() {
|
||||
it('fires pointerup events', function() {
|
||||
_ol_events_.listen(handler, 'pointerup', eventSpy);
|
||||
listen(handler, 'pointerup', eventSpy);
|
||||
simulateEvent('mousedown', 0, 0);
|
||||
simulateEvent('mouseup', 0, 0);
|
||||
expect(eventSpy.calledOnce).to.be.ok();
|
||||
@@ -69,7 +69,7 @@ describe('ol.pointer.PointerEventHandler', function() {
|
||||
|
||||
describe('pointer move', function() {
|
||||
it('fires pointermove events', function() {
|
||||
_ol_events_.listen(handler, 'pointermove', eventSpy);
|
||||
listen(handler, 'pointermove', eventSpy);
|
||||
simulateEvent('mousemove', 0, 0);
|
||||
expect(eventSpy.calledOnce).to.be.ok();
|
||||
});
|
||||
@@ -80,8 +80,8 @@ describe('ol.pointer.PointerEventHandler', function() {
|
||||
const enterEventSpy = sinon.spy();
|
||||
const overEventSpy = sinon.spy();
|
||||
|
||||
_ol_events_.listen(handler, 'pointerenter', enterEventSpy);
|
||||
_ol_events_.listen(handler, 'pointerover', overEventSpy);
|
||||
listen(handler, 'pointerenter', enterEventSpy);
|
||||
listen(handler, 'pointerover', overEventSpy);
|
||||
|
||||
simulateEvent('mouseover', 0, 0);
|
||||
|
||||
@@ -95,8 +95,8 @@ describe('ol.pointer.PointerEventHandler', function() {
|
||||
const leaveEventSpy = sinon.spy();
|
||||
const outEventSpy = sinon.spy();
|
||||
|
||||
_ol_events_.listen(handler, 'pointerleave', leaveEventSpy);
|
||||
_ol_events_.listen(handler, 'pointerout', outEventSpy);
|
||||
listen(handler, 'pointerleave', leaveEventSpy);
|
||||
listen(handler, 'pointerout', outEventSpy);
|
||||
|
||||
simulateEvent('mouseout', 0, 0);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import Event from '../../../../src/ol/events/Event.js';
|
||||
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_has_ from '../../../../src/ol/has.js';
|
||||
@@ -28,7 +28,7 @@ describe('ol.pointer.TouchSource', function() {
|
||||
|
||||
describe('pointer event creation', function() {
|
||||
it('generates pointer events for each touch contact', function() {
|
||||
_ol_events_.listen(handler, 'pointerdown', eventSpy);
|
||||
listen(handler, 'pointerdown', eventSpy);
|
||||
|
||||
simulateTouchEvent('touchstart', [
|
||||
{identifier: 3, clientX: 10, clientY: 11},
|
||||
@@ -55,7 +55,7 @@ describe('ol.pointer.TouchSource', function() {
|
||||
});
|
||||
|
||||
it('creates the right pointer events', function() {
|
||||
_ol_events_.listen(handler, 'pointerdown', eventSpy);
|
||||
listen(handler, 'pointerdown', eventSpy);
|
||||
|
||||
// first touch
|
||||
simulateTouchEvent('touchstart', [
|
||||
@@ -74,7 +74,7 @@ describe('ol.pointer.TouchSource', function() {
|
||||
|
||||
// first touch moves
|
||||
const moveEventSpy = sinon.spy();
|
||||
_ol_events_.listen(handler, 'pointermove', moveEventSpy);
|
||||
listen(handler, 'pointermove', moveEventSpy);
|
||||
|
||||
simulateTouchEvent('touchmove', [
|
||||
{identifier: 3, clientX: 15, clientY: 16}
|
||||
@@ -84,7 +84,7 @@ describe('ol.pointer.TouchSource', function() {
|
||||
|
||||
// and then both touches go up
|
||||
const upEventSpy = sinon.spy();
|
||||
_ol_events_.listen(handler, 'pointerup', upEventSpy);
|
||||
listen(handler, 'pointerup', upEventSpy);
|
||||
|
||||
simulateTouchEvent('touchend', [
|
||||
{identifier: 3, clientX: 15, clientY: 16},
|
||||
@@ -96,7 +96,7 @@ describe('ol.pointer.TouchSource', function() {
|
||||
});
|
||||
|
||||
it('handles flawed touches', function() {
|
||||
_ol_events_.listen(handler, 'pointerdown', eventSpy);
|
||||
listen(handler, 'pointerdown', eventSpy);
|
||||
|
||||
// first touch
|
||||
simulateTouchEvent('touchstart', [
|
||||
@@ -107,7 +107,7 @@ describe('ol.pointer.TouchSource', function() {
|
||||
|
||||
// second touch, but the first touch has disappeared
|
||||
const cancelEventSpy = sinon.spy();
|
||||
_ol_events_.listen(handler, 'pointercancel', cancelEventSpy);
|
||||
listen(handler, 'pointercancel', cancelEventSpy);
|
||||
simulateTouchEvent('touchstart', [
|
||||
{identifier: 4, clientX: 30, clientY: 45}
|
||||
], [{identifier: 4}]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_events_ from '../../../../../src/ol/events.js';
|
||||
import {listen, unlisten} from '../../../../../src/ol/events.js';
|
||||
import {clear} from '../../../../../src/ol/obj.js';
|
||||
import _ol_render_canvas_ from '../../../../../src/ol/render/canvas.js';
|
||||
|
||||
@@ -24,11 +24,11 @@ describe('ol.render.canvas', function() {
|
||||
it('does not clear label cache and measurements for unavailable fonts', function(done) {
|
||||
this.timeout(3000);
|
||||
const spy = sinon.spy();
|
||||
_ol_events_.listen(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
listen(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
const interval = setInterval(function() {
|
||||
if (_ol_render_canvas_.checkedFonts_['foo'] == retries && _ol_render_canvas_.checkedFonts_['sans-serif'] == retries) {
|
||||
clearInterval(interval);
|
||||
_ol_events_.unlisten(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
unlisten(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
expect(spy.callCount).to.be(0);
|
||||
expect(_ol_render_canvas_.measureContext_).to.not.be(null);
|
||||
expect(_ol_render_canvas_.textHeights_).to.not.eql({});
|
||||
@@ -40,11 +40,11 @@ describe('ol.render.canvas', function() {
|
||||
|
||||
it('does not clear label cache and measurements for available fonts', function(done) {
|
||||
const spy = sinon.spy();
|
||||
_ol_events_.listen(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
listen(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
const interval = setInterval(function() {
|
||||
if (_ol_render_canvas_.checkedFonts_['sans-serif'] == retries) {
|
||||
clearInterval(interval);
|
||||
_ol_events_.unlisten(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
unlisten(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
expect(spy.callCount).to.be(0);
|
||||
expect(_ol_render_canvas_.measureContext_).to.not.be(null);
|
||||
expect(_ol_render_canvas_.textHeights_).to.not.eql({});
|
||||
@@ -56,11 +56,11 @@ describe('ol.render.canvas', function() {
|
||||
|
||||
it('does not clear label cache and measurements for the \'monospace\' font', function(done) {
|
||||
const spy = sinon.spy();
|
||||
_ol_events_.listen(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
listen(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
const interval = setInterval(function() {
|
||||
if (_ol_render_canvas_.checkedFonts_['monospace'] == retries) {
|
||||
clearInterval(interval);
|
||||
_ol_events_.unlisten(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
unlisten(_ol_render_canvas_.labelCache, 'clear', spy);
|
||||
expect(spy.callCount).to.be(0);
|
||||
expect(_ol_render_canvas_.measureContext_).to.not.be(null);
|
||||
expect(_ol_render_canvas_.textHeights_).to.not.eql({});
|
||||
@@ -72,7 +72,7 @@ describe('ol.render.canvas', function() {
|
||||
|
||||
it('clears label cache and measurements for fonts that become available', function(done) {
|
||||
head.appendChild(font);
|
||||
_ol_events_.listen(_ol_render_canvas_.labelCache, 'clear', function() {
|
||||
listen(_ol_render_canvas_.labelCache, 'clear', function() {
|
||||
expect(_ol_render_canvas_.measureContext_).to.be(null);
|
||||
expect(_ol_render_canvas_.textHeights_).to.eql({});
|
||||
done();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {nullFunction} from '../../../../src/ol/index.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {getListeners} from '../../../../src/ol/events.js';
|
||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||
import Point from '../../../../src/ol/geom/Point.js';
|
||||
import Polygon from '../../../../src/ol/geom/Polygon.js';
|
||||
@@ -54,7 +54,7 @@ describe('ol.renderer.vector', function() {
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
|
||||
expect(iconStyleLoadSpy.calledOnce).to.be.ok();
|
||||
listeners = _ol_events_.getListeners(
|
||||
listeners = getListeners(
|
||||
iconStyle.iconImage_, 'change');
|
||||
expect(listeners.length).to.eql(1);
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('ol.renderer.vector', function() {
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
|
||||
expect(iconStyleLoadSpy.calledOnce).to.be.ok();
|
||||
listeners = _ol_events_.getListeners(
|
||||
listeners = getListeners(
|
||||
iconStyle.iconImage_, 'change');
|
||||
expect(listeners.length).to.eql(1);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _ol_Image_ from '../../../../src/ol/Image.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
import ReprojImage from '../../../../src/ol/reproj/Image.js';
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('ol.reproj.Image', function() {
|
||||
it('changes state as expected', function(done) {
|
||||
const image = createImage(1);
|
||||
expect(image.getState()).to.be(0); // IDLE
|
||||
_ol_events_.listen(image, 'change', function() {
|
||||
listen(image, 'change', function() {
|
||||
if (image.getState() == 2) { // LOADED
|
||||
done();
|
||||
}
|
||||
@@ -32,7 +32,7 @@ describe('ol.reproj.Image', function() {
|
||||
|
||||
it('returns correct canvas size', function(done) {
|
||||
const image = createImage(1);
|
||||
_ol_events_.listen(image, 'change', function() {
|
||||
listen(image, 'change', function() {
|
||||
if (image.getState() == 2) { // LOADED
|
||||
const canvas = image.getImage();
|
||||
expect(canvas.width).to.be(36);
|
||||
@@ -45,7 +45,7 @@ describe('ol.reproj.Image', function() {
|
||||
|
||||
it('respects pixelRatio', function(done) {
|
||||
const image = createImage(2);
|
||||
_ol_events_.listen(image, 'change', function() {
|
||||
listen(image, 'change', function() {
|
||||
if (image.getState() == 2) { // LOADED
|
||||
const canvas = image.getImage();
|
||||
expect(canvas.width).to.be(72);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import ImageTile from '../../../../src/ol/ImageTile.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js';
|
||||
import {register} from '../../../../src/ol/proj/proj4.js';
|
||||
import ReprojTile from '../../../../src/ol/reproj/Tile.js';
|
||||
@@ -43,7 +43,7 @@ describe('ol.reproj.Tile', function() {
|
||||
it('changes state as expected', function(done) {
|
||||
const tile = createTile(1);
|
||||
expect(tile.getState()).to.be(0); // IDLE
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
done();
|
||||
}
|
||||
@@ -77,7 +77,7 @@ describe('ol.reproj.Tile', function() {
|
||||
|
||||
it('respects tile size of target tile grid', function(done) {
|
||||
const tile = createTile(1, [100, 40]);
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
const canvas = tile.getImage();
|
||||
expect(canvas.width).to.be(100);
|
||||
@@ -90,7 +90,7 @@ describe('ol.reproj.Tile', function() {
|
||||
|
||||
it('respects pixelRatio', function(done) {
|
||||
const tile = createTile(3, [60, 20]);
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
const canvas = tile.getImage();
|
||||
expect(canvas.width).to.be(180);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import ImageTile from '../../../../src/ol/ImageTile.js';
|
||||
import TileState from '../../../../src/ol/TileState.js';
|
||||
import {createFromTemplate} from '../../../../src/ol/tileurlfunction.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js';
|
||||
import {register} from '../../../../src/ol/proj/proj4.js';
|
||||
import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js';
|
||||
@@ -148,7 +148,7 @@ describe('ol.source.TileImage', function() {
|
||||
const tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
expect(tile).to.be.a(ReprojTile);
|
||||
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
done();
|
||||
}
|
||||
@@ -167,7 +167,7 @@ describe('ol.source.TileImage', function() {
|
||||
const tile = source.getTile(0, 0, -1, 1, proj);
|
||||
expect(tile).to.be.a(ReprojTile);
|
||||
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
done();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import Collection from '../../../../src/ol/Collection.js';
|
||||
import Feature from '../../../../src/ol/Feature.js';
|
||||
import Map from '../../../../src/ol/Map.js';
|
||||
@@ -67,7 +67,7 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('fires a change event', function() {
|
||||
const listener = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', listener);
|
||||
listen(vectorSource, 'change', listener);
|
||||
vectorSource.addFeature(pointFeature);
|
||||
expect(listener).to.be.called();
|
||||
});
|
||||
@@ -139,11 +139,11 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('removes all features using fast path', function() {
|
||||
const changeSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', changeSpy);
|
||||
listen(vectorSource, 'change', changeSpy);
|
||||
const removeFeatureSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'removefeature', removeFeatureSpy);
|
||||
listen(vectorSource, 'removefeature', removeFeatureSpy);
|
||||
const clearSourceSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'clear', clearSourceSpy);
|
||||
listen(vectorSource, 'clear', clearSourceSpy);
|
||||
vectorSource.clear(true);
|
||||
expect(vectorSource.getFeatures()).to.eql([]);
|
||||
expect(vectorSource.isEmpty()).to.be(true);
|
||||
@@ -157,11 +157,11 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('removes all features using slow path', function() {
|
||||
const changeSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', changeSpy);
|
||||
listen(vectorSource, 'change', changeSpy);
|
||||
const removeFeatureSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'removefeature', removeFeatureSpy);
|
||||
listen(vectorSource, 'removefeature', removeFeatureSpy);
|
||||
const clearSourceSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'clear', clearSourceSpy);
|
||||
listen(vectorSource, 'clear', clearSourceSpy);
|
||||
vectorSource.clear();
|
||||
expect(vectorSource.getFeatures()).to.eql([]);
|
||||
expect(vectorSource.isEmpty()).to.be(true);
|
||||
@@ -225,7 +225,7 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('fires a change event', function() {
|
||||
const listener = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', listener);
|
||||
listen(vectorSource, 'change', listener);
|
||||
vectorSource.removeFeature(features[0]);
|
||||
expect(listener).to.be.called();
|
||||
});
|
||||
@@ -311,7 +311,7 @@ describe('ol.source.Vector', function() {
|
||||
const feature = new Feature(new Point([1, 1]));
|
||||
vectorSource.addFeature(feature);
|
||||
const listener = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', listener);
|
||||
listen(vectorSource, 'change', listener);
|
||||
feature.set('foo', 'bar');
|
||||
expect(listener).to.be.called();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {DEFAULT_TILE_SIZE} from '../../../../src/ol/tilegrid/common.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import Projection from '../../../../src/ol/proj/Projection.js';
|
||||
import Zoomify from '../../../../src/ol/source/Zoomify.js';
|
||||
import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
@@ -301,7 +301,7 @@ describe('ol.source.Zoomify', function() {
|
||||
|
||||
const tile = source.getTile(0, 0, -1, 1, proj);
|
||||
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
const img = tile.getImage();
|
||||
expect(img).to.be.a(HTMLCanvasElement);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {nullFunction} from '../../../../src/ol/index.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import {iconImageCache} from '../../../../src/ol/style.js';
|
||||
import IconImage from '../../../../src/ol/style/IconImage.js';
|
||||
|
||||
@@ -42,13 +42,13 @@ describe('ol.style.IconImageCache', function() {
|
||||
|
||||
src = '0';
|
||||
iconImage = new IconImage(null, src);
|
||||
_ol_events_.listen(iconImage, 'change', nullFunction, false);
|
||||
listen(iconImage, 'change', nullFunction, false);
|
||||
iconImageCache.set(src, null, null, iconImage);
|
||||
expect(iconImageCache.cacheSize_).to.eql(4);
|
||||
|
||||
src = '4';
|
||||
iconImage = new IconImage(null, src);
|
||||
_ol_events_.listen(iconImage, 'change', nullFunction, false);
|
||||
listen(iconImage, 'change', nullFunction, false);
|
||||
iconImageCache.set(src, null, null, iconImage);
|
||||
expect(iconImageCache.cacheSize_).to.eql(5);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import TileState from '../../../src/ol/TileState.js';
|
||||
import VectorImageTile, {defaultLoadFunction} from '../../../src/ol/VectorImageTile.js';
|
||||
import VectorTile from '../../../src/ol/VectorTile.js';
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import {listen, listenOnce} from '../../../src/ol/events.js';
|
||||
import GeoJSON from '../../../src/ol/format/GeoJSON.js';
|
||||
import {get as getProjection} from '../../../src/ol/proj.js';
|
||||
import _ol_tilegrid_ from '../../../src/ol/tilegrid.js';
|
||||
@@ -24,7 +24,7 @@ describe('ol.VectorImageTile', function() {
|
||||
const loader = sourceTile.loader_;
|
||||
expect(typeof loader).to.be('function');
|
||||
|
||||
_ol_events_.listen(sourceTile, 'change', function(e) {
|
||||
listen(sourceTile, 'change', function(e) {
|
||||
expect(sourceTile.getFeatures().length).to.be.greaterThan(0);
|
||||
done();
|
||||
});
|
||||
@@ -45,7 +45,7 @@ describe('ol.VectorImageTile', function() {
|
||||
|
||||
tile.load();
|
||||
let calls = 0;
|
||||
_ol_events_.listen(tile, 'change', function(e) {
|
||||
listen(tile, 'change', function(e) {
|
||||
++calls;
|
||||
expect(tile.getState()).to.be(calls == 2 ? TileState.LOADED : TileState.ERROR);
|
||||
if (calls == 2) {
|
||||
@@ -69,7 +69,7 @@ describe('ol.VectorImageTile', function() {
|
||||
|
||||
tile.load();
|
||||
|
||||
_ol_events_.listen(tile, 'change', function(e) {
|
||||
listen(tile, 'change', function(e) {
|
||||
expect(tile.getState()).to.be(TileState.ERROR);
|
||||
done();
|
||||
});
|
||||
@@ -85,7 +85,7 @@ describe('ol.VectorImageTile', function() {
|
||||
|
||||
tile.load();
|
||||
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
listen(tile, 'change', function() {
|
||||
expect(tile.getState()).to.be(TileState.EMPTY);
|
||||
done();
|
||||
});
|
||||
@@ -141,7 +141,7 @@ describe('ol.VectorImageTile', function() {
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {});
|
||||
|
||||
tile.load();
|
||||
_ol_events_.listenOnce(tile, 'change', function() {
|
||||
listenOnce(tile, 'change', function() {
|
||||
expect(tile.getState()).to.be(TileState.LOADED);
|
||||
expect(tile.loadListenerKeys_.length).to.be(0);
|
||||
expect(tile.tileKeys.length).to.be(4);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Feature from '../../../src/ol/Feature.js';
|
||||
import {defaultLoadFunction} from '../../../src/ol/VectorImageTile.js';
|
||||
import VectorTile from '../../../src/ol/VectorTile.js';
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import {listen} from '../../../src/ol/events.js';
|
||||
import TextFeature from '../../../src/ol/format/TextFeature.js';
|
||||
import {get as getProjection} from '../../../src/ol/proj.js';
|
||||
import Projection from '../../../src/ol/proj/Projection.js';
|
||||
@@ -27,7 +27,7 @@ describe('ol.VectorTile', function() {
|
||||
|
||||
defaultLoadFunction(tile, url);
|
||||
const loader = tile.loader_;
|
||||
_ol_events_.listen(tile, 'change', function(e) {
|
||||
listen(tile, 'change', function(e) {
|
||||
expect(tile.getFeatures().length).to.be.greaterThan(0);
|
||||
expect(tile.getProjection().getUnits()).to.be('tile-pixels');
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user