Rename _ol_Collection_ to Collection

This commit is contained in:
Tim Schaub
2018-01-11 10:32:24 -07:00
parent 84e93efe5c
commit 176021e188
17 changed files with 117 additions and 117 deletions

View File

@@ -1,5 +1,5 @@
import _ol_events_ from '../../../src/ol/events.js';
import _ol_Collection_ from '../../../src/ol/Collection.js';
import Collection from '../../../src/ol/Collection.js';
import CollectionEventType from '../../../src/ol/CollectionEventType.js';
@@ -7,7 +7,7 @@ describe('ol.collection', function() {
var collection;
beforeEach(function() {
collection = new _ol_Collection_();
collection = new Collection();
});
describe('create an empty collection', function() {
@@ -21,7 +21,7 @@ describe('ol.collection', function() {
describe('create a collection from an array', function() {
it('creates the expected collection', function() {
var array = [0, 1, 2];
var collection = new _ol_Collection_(array);
var collection = new Collection(array);
expect(collection.item(0)).to.eql(0);
expect(collection.item(1)).to.eql(1);
expect(collection.item(2)).to.eql(2);
@@ -61,7 +61,7 @@ describe('ol.collection', function() {
describe('insertAt', function() {
it('inserts elements at the correct location', function() {
collection = new _ol_Collection_([0, 2]);
collection = new Collection([0, 2]);
collection.insertAt(1, 1);
expect(collection.item(0)).to.eql(0);
expect(collection.item(1)).to.eql(1);
@@ -80,7 +80,7 @@ describe('ol.collection', function() {
describe('removeAt', function() {
it('removes elements at the correction', function() {
var collection = new _ol_Collection_([0, 1, 2]);
var collection = new Collection([0, 1, 2]);
collection.removeAt(1);
expect(collection.item(0)).to.eql(0);
expect(collection.item(1)).to.eql(2);
@@ -110,13 +110,13 @@ describe('ol.collection', function() {
describe('remove', function() {
it('removes the first matching element', function() {
var collection = new _ol_Collection_([0, 1, 2]);
var collection = new Collection([0, 1, 2]);
expect(collection.remove(1)).to.eql(1);
expect(collection.getArray()).to.eql([0, 2]);
expect(collection.getLength()).to.eql(2);
});
it('fires a remove event', function() {
var collection = new _ol_Collection_([0, 1, 2]);
var collection = new Collection([0, 1, 2]);
var cb = sinon.spy();
_ol_events_.listen(collection, CollectionEventType.REMOVE, cb);
expect(collection.remove(1)).to.eql(1);
@@ -124,13 +124,13 @@ describe('ol.collection', function() {
expect(cb.lastCall.args[0].element).to.eql(1);
});
it('does not remove more than one matching element', function() {
var collection = new _ol_Collection_([0, 1, 1, 2]);
var collection = new Collection([0, 1, 1, 2]);
expect(collection.remove(1)).to.eql(1);
expect(collection.getArray()).to.eql([0, 1, 2]);
expect(collection.getLength()).to.eql(3);
});
it('returns undefined if the element is not found', function() {
var collection = new _ol_Collection_([0, 1, 2]);
var collection = new Collection([0, 1, 2]);
expect(collection.remove(3)).to.be(undefined);
expect(collection.getArray()).to.eql([0, 1, 2]);
expect(collection.getLength()).to.eql(3);
@@ -139,7 +139,7 @@ describe('ol.collection', function() {
describe('setAt and event', function() {
it('does dispatch events', function() {
var collection = new _ol_Collection_(['a', 'b']);
var collection = new Collection(['a', 'b']);
var added, removed;
_ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
added = e.element;
@@ -156,7 +156,7 @@ describe('ol.collection', function() {
describe('removeAt and event', function() {
it('does dispatch events', function() {
var collection = new _ol_Collection_(['a']);
var collection = new Collection(['a']);
var removed;
_ol_events_.listen(
collection, CollectionEventType.REMOVE, function(e) {
@@ -169,7 +169,7 @@ describe('ol.collection', function() {
describe('insertAt and event', function() {
it('does dispatch events', function() {
var collection = new _ol_Collection_([0, 2]);
var collection = new Collection([0, 2]);
var added;
_ol_events_.listen(
collection, CollectionEventType.ADD, function(e) {
@@ -202,7 +202,7 @@ describe('ol.collection', function() {
describe('change:length event', function() {
var collection, cb;
beforeEach(function() {
collection = new _ol_Collection_([0, 1, 2]);
collection = new Collection([0, 1, 2]);
cb = sinon.spy();
_ol_events_.listen(collection, 'change:length', cb);
});
@@ -231,7 +231,7 @@ describe('ol.collection', function() {
describe('add event', function() {
it('triggers add when pushing', function() {
var collection = new _ol_Collection_();
var collection = new Collection();
var elem;
_ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
elem = e.element;
@@ -244,7 +244,7 @@ describe('ol.collection', function() {
describe('remove event', function() {
var collection, cb1, cb2;
beforeEach(function() {
collection = new _ol_Collection_([1]);
collection = new Collection([1]);
cb1 = sinon.spy();
cb2 = sinon.spy();
});
@@ -275,7 +275,7 @@ describe('ol.collection', function() {
expect(collection.item(1)).to.eql(2);
});
it('fires events', function() {
var collection = new _ol_Collection_();
var collection = new Collection();
var elems = [];
_ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
elems.push(e.element);
@@ -287,25 +287,25 @@ describe('ol.collection', function() {
describe('unique collection', function() {
it('allows unique items in the constructor', function() {
new _ol_Collection_([{}, {}, {}], {unique: true});
new Collection([{}, {}, {}], {unique: true});
});
it('throws if duplicate items are passed to the constructor', function() {
var item = {};
var call = function() {
new _ol_Collection_([item, item], {unique: true});
new Collection([item, item], {unique: true});
};
expect(call).to.throwException();
});
it('allows unique items to be added via push', function() {
var unique = new _ol_Collection_(undefined, {unique: true});
var unique = new Collection(undefined, {unique: true});
unique.push({});
unique.push({});
});
it('throws if duplicate items are added via push', function() {
var unique = new _ol_Collection_(undefined, {unique: true});
var unique = new Collection(undefined, {unique: true});
var item = {};
unique.push(item);
var call = function() {
@@ -315,13 +315,13 @@ describe('ol.collection', function() {
});
it('allows unique items to be added via insertAt', function() {
var unique = new _ol_Collection_(undefined, {unique: true});
var unique = new Collection(undefined, {unique: true});
unique.insertAt(0, {});
unique.insertAt(0, {});
});
it('throws if duplicate items are added via insertAt', function() {
var unique = new _ol_Collection_(undefined, {unique: true});
var unique = new Collection(undefined, {unique: true});
var item = {};
unique.insertAt(0, item);
var call = function() {
@@ -331,20 +331,20 @@ describe('ol.collection', function() {
});
it('allows unique items to be added via setAt', function() {
var unique = new _ol_Collection_(undefined, {unique: true});
var unique = new Collection(undefined, {unique: true});
unique.setAt(0, {});
unique.setAt(1, {});
});
it('allows items to be reset via setAt', function() {
var unique = new _ol_Collection_(undefined, {unique: true});
var unique = new Collection(undefined, {unique: true});
var item = {};
unique.setAt(0, item);
unique.setAt(0, item);
});
it('throws if duplicate items are added via setAt', function() {
var unique = new _ol_Collection_(undefined, {unique: true});
var unique = new Collection(undefined, {unique: true});
var item = {};
unique.setAt(0, item);
var call = function() {

View File

@@ -1,4 +1,4 @@
import _ol_Collection_ from '../../../../src/ol/Collection.js';
import Collection from '../../../../src/ol/Collection.js';
import Feature from '../../../../src/ol/Feature.js';
import Map from '../../../../src/ol/Map.js';
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
@@ -153,7 +153,7 @@ describe('ol.interaction.Modify', function() {
it('adds features to the RTree', function() {
var feature = new Feature(
new Point([0, 0]));
var features = new _ol_Collection_([feature]);
var features = new Collection([feature]);
var modify = new _ol_interaction_Modify_({
features: features
});
@@ -164,7 +164,7 @@ describe('ol.interaction.Modify', function() {
it('accepts feature without geometry', function() {
var feature = new Feature();
var features = new _ol_Collection_([feature]);
var features = new Collection([feature]);
var modify = new _ol_interaction_Modify_({
features: features
});
@@ -200,7 +200,7 @@ describe('ol.interaction.Modify', function() {
var secondRevision = second.getGeometry().getRevision();
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
@@ -238,7 +238,7 @@ describe('ol.interaction.Modify', function() {
var firstRevision = first.getGeometry().getRevision();
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
@@ -274,7 +274,7 @@ describe('ol.interaction.Modify', function() {
var firstRevision = first.getGeometry().getRevision();
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
@@ -310,7 +310,7 @@ describe('ol.interaction.Modify', function() {
var firstRevision = first.getGeometry().getRevision();
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
@@ -348,7 +348,7 @@ describe('ol.interaction.Modify', function() {
features.push(lineFeature);
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
@@ -387,7 +387,7 @@ describe('ol.interaction.Modify', function() {
features.push(circleFeature);
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
@@ -418,7 +418,7 @@ describe('ol.interaction.Modify', function() {
beforeEach(function() {
modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
@@ -523,7 +523,7 @@ describe('ol.interaction.Modify', function() {
beforeEach(function() {
modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features),
features: new Collection(features),
deleteCondition: _ol_events_condition_.doubleClick
});
map.addInteraction(modify);
@@ -576,7 +576,7 @@ describe('ol.interaction.Modify', function() {
});
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features),
features: new Collection(features),
insertVertexCondition: listenerSpy
});
map.addInteraction(modify);
@@ -622,7 +622,7 @@ describe('ol.interaction.Modify', function() {
features.push(feature);
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
@@ -658,7 +658,7 @@ describe('ol.interaction.Modify', function() {
it('updates polygon segment data', function() {
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
@@ -698,7 +698,7 @@ describe('ol.interaction.Modify', function() {
describe('#setActive', function() {
it('removes the vertexFeature of deactivation', function() {
var modify = new _ol_interaction_Modify_({
features: new _ol_Collection_(features)
features: new Collection(features)
});
map.addInteraction(modify);
expect(modify.vertexFeature_).to.be(null);

View File

@@ -1,4 +1,4 @@
import _ol_Collection_ from '../../../../src/ol/Collection.js';
import Collection from '../../../../src/ol/Collection.js';
import Feature from '../../../../src/ol/Feature.js';
import Map from '../../../../src/ol/Map.js';
import MapBrowserEventType from '../../../../src/ol/MapBrowserEventType.js';
@@ -111,7 +111,7 @@ describe('ol.interaction.Select', function() {
describe('user-provided collection', function() {
it('uses the user-provided collection', function() {
var features = new _ol_Collection_();
var features = new Collection();
var select = new _ol_interaction_Select_({features: features});
expect(select.getFeatures()).to.be(features);
});

View File

@@ -1,4 +1,4 @@
import _ol_Collection_ from '../../../../src/ol/Collection.js';
import Collection from '../../../../src/ol/Collection.js';
import Feature from '../../../../src/ol/Feature.js';
import Map from '../../../../src/ol/Map.js';
import View from '../../../../src/ol/View.js';
@@ -58,7 +58,7 @@ describe('ol.interaction.Snap', function() {
it('can handle XYZ coordinates', function() {
var point = new Feature(new Point([0, 0, 123]));
var snapInteraction = new _ol_interaction_Snap_({
features: new _ol_Collection_([point])
features: new Collection([point])
});
snapInteraction.setMap(map);
@@ -75,7 +75,7 @@ describe('ol.interaction.Snap', function() {
it('snaps to edges only', function() {
var point = new Feature(new LineString([[-10, 0], [10, 0]]));
var snapInteraction = new _ol_interaction_Snap_({
features: new _ol_Collection_([point]),
features: new Collection([point]),
pixelTolerance: 5,
vertex: false
});
@@ -93,7 +93,7 @@ describe('ol.interaction.Snap', function() {
it('snaps to vertices only', function() {
var point = new Feature(new LineString([[-10, 0], [10, 0]]));
var snapInteraction = new _ol_interaction_Snap_({
features: new _ol_Collection_([point]),
features: new Collection([point]),
pixelTolerance: 5,
edge: false
});
@@ -111,7 +111,7 @@ describe('ol.interaction.Snap', function() {
it('snaps to circle', function() {
var circle = new Feature(new Circle([0, 0], 10));
var snapInteraction = new _ol_interaction_Snap_({
features: new _ol_Collection_([circle]),
features: new Collection([circle]),
pixelTolerance: 5
});
snapInteraction.setMap(map);
@@ -130,7 +130,7 @@ describe('ol.interaction.Snap', function() {
it('handle feature without geometry', function() {
var feature = new Feature();
var snapInteraction = new _ol_interaction_Snap_({
features: new _ol_Collection_([feature]),
features: new Collection([feature]),
pixelTolerance: 5,
edge: false
});
@@ -150,7 +150,7 @@ describe('ol.interaction.Snap', function() {
it('handle geometry changes', function() {
var line = new Feature(new LineString([[-10, 0], [0, 0]]));
var snapInteraction = new _ol_interaction_Snap_({
features: new _ol_Collection_([line]),
features: new Collection([line]),
pixelTolerance: 5,
edge: false
});
@@ -173,7 +173,7 @@ describe('ol.interaction.Snap', function() {
alt_geometry: new LineString([[-10, 0], [10, 0]])
});
var snapInteraction = new _ol_interaction_Snap_({
features: new _ol_Collection_([line]),
features: new Collection([line]),
pixelTolerance: 5,
edge: false
});

View File

@@ -1,4 +1,4 @@
import _ol_Collection_ from '../../../../src/ol/Collection.js';
import Collection from '../../../../src/ol/Collection.js';
import Feature from '../../../../src/ol/Feature.js';
import Map from '../../../../src/ol/Map.js';
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
@@ -159,7 +159,7 @@ describe('ol.interaction.Translate', function() {
beforeEach(function() {
translate = new _ol_interaction_Translate_({
features: new _ol_Collection_([features[0]])
features: new Collection([features[0]])
});
map.addInteraction(translate);
});

View File

@@ -1,6 +1,6 @@
import {getUid} from '../../../../src/ol/index.js';
import {stableSort} from '../../../../src/ol/array.js';
import _ol_Collection_ from '../../../../src/ol/Collection.js';
import Collection from '../../../../src/ol/Collection.js';
import * as _ol_extent_ from '../../../../src/ol/extent.js';
import LayerGroup from '../../../../src/ol/layer/Group.js';
import Layer from '../../../../src/ol/layer/Layer.js';
@@ -50,7 +50,7 @@ describe('ol.layer.Group', function() {
});
it('provides default empty layers collection', function() {
expect(layerGroup.getLayers()).to.be.a(_ol_Collection_);
expect(layerGroup.getLayers()).to.be.a(Collection);
expect(layerGroup.getLayers().getLength()).to.be(0);
});
@@ -166,7 +166,7 @@ describe('ol.layer.Group', function() {
maxResolution: 500,
minResolution: 0.25
});
expect(layerGroup.getLayers()).to.be.a(_ol_Collection_);
expect(layerGroup.getLayers()).to.be.a(Collection);
expect(layerGroup.getLayers().getLength()).to.be(1);
expect(layerGroup.getLayers().item(0)).to.be(layer);
@@ -207,7 +207,7 @@ describe('ol.layer.Group', function() {
maxResolution: 500,
minResolution: 0.25
});
expect(layerGroup.getLayers()).to.be.a(_ol_Collection_);
expect(layerGroup.getLayers()).to.be.a(Collection);
expect(layerGroup.getLayers().getLength()).to.be(1);
expect(layerGroup.getLayers().item(0)).to.be(layer);
@@ -284,7 +284,7 @@ describe('ol.layer.Group', function() {
describe('layers events', function() {
it('listen / unlisten for layers added to the collection', function() {
var layers = new _ol_Collection_();
var layers = new Collection();
var layerGroup = new LayerGroup({
layers: layers
});
@@ -315,7 +315,7 @@ describe('ol.layer.Group', function() {
projection: 'EPSG:4326'
})
});
var layers = new _ol_Collection_([layer]);
var layers = new Collection([layer]);
var layerGroup = new LayerGroup();
layerGroup.setLayers(layers);

View File

@@ -1,5 +1,5 @@
import _ol_events_ from '../../../../src/ol/events.js';
import _ol_Collection_ from '../../../../src/ol/Collection.js';
import Collection from '../../../../src/ol/Collection.js';
import Feature from '../../../../src/ol/Feature.js';
import Map from '../../../../src/ol/Map.js';
import View from '../../../../src/ol/View.js';
@@ -560,7 +560,7 @@ describe('ol.source.Vector', function() {
});
it('returns a features collection', function() {
expect(source.getFeaturesCollection()).to.be.a(_ol_Collection_);
expect(source.getFeaturesCollection()).to.be.a(Collection);
});
it('#forEachFeatureInExtent loops through all features', function() {
@@ -622,7 +622,7 @@ describe('ol.source.Vector', function() {
describe('with a collection of features plus spatial index', function() {
var collection, source;
beforeEach(function() {
collection = new _ol_Collection_();
collection = new Collection();
source = new VectorSource({
features: collection
});