Rename _ol_Feature_ to Feature

This commit is contained in:
Tim Schaub
2018-01-08 09:35:02 -07:00
parent 6934e148ca
commit 22fce4f97b
79 changed files with 630 additions and 630 deletions

View File

@@ -1,4 +1,4 @@
import _ol_Feature_ from '../../../src/ol/Feature.js';
import Feature from '../../../src/ol/Feature.js';
import Point from '../../../src/ol/geom/Point.js';
import _ol_obj_ from '../../../src/ol/obj.js';
import _ol_style_Style_ from '../../../src/ol/style/Style.js';
@@ -9,25 +9,25 @@ describe('ol.Feature', function() {
describe('constructor', function() {
it('creates a new feature', function() {
var feature = new _ol_Feature_();
expect(feature).to.be.a(_ol_Feature_);
var feature = new Feature();
expect(feature).to.be.a(Feature);
});
it('takes properties', function() {
var feature = new _ol_Feature_({
var feature = new Feature({
foo: 'bar'
});
expect(feature.get('foo')).to.be('bar');
});
it('can store the feature\'s commonly used id', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setId('foo');
expect(feature.getId()).to.be('foo');
});
it('will set the default geometry', function() {
var feature = new _ol_Feature_({
var feature = new Feature({
geometry: new Point([10, 20]),
foo: 'bar'
});
@@ -41,7 +41,7 @@ describe('ol.Feature', function() {
describe('#get()', function() {
it('returns values set at construction', function() {
var feature = new _ol_Feature_({
var feature = new Feature({
a: 'first',
b: 'second'
});
@@ -50,12 +50,12 @@ describe('ol.Feature', function() {
});
it('returns undefined for unset attributes', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
expect(feature.get('a')).to.be(undefined);
});
it('returns values set by set', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.set('a', 'b');
expect(feature.get('a')).to.be('b');
});
@@ -66,7 +66,7 @@ describe('ol.Feature', function() {
it('returns an object with all attributes', function() {
var point = new Point([15, 30]);
var feature = new _ol_Feature_({
var feature = new Feature({
foo: 'bar',
ten: 10,
geometry: point
@@ -83,7 +83,7 @@ describe('ol.Feature', function() {
});
it('is empty by default', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
var properties = feature.getProperties();
expect(_ol_obj_.isEmpty(properties)).to.be(true);
});
@@ -96,30 +96,30 @@ describe('ol.Feature', function() {
var point = new Point([15, 30]);
it('returns undefined for unset geometry', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
expect(feature.getGeometry()).to.be(undefined);
});
it('returns null for null geometry (constructor)', function() {
var feature = new _ol_Feature_(null);
var feature = new Feature(null);
expect(feature.getGeometry()).to.be(null);
});
it('returns null for null geometry (setGeometry())', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setGeometry(null);
expect(feature.getGeometry()).to.be(null);
});
it('gets the geometry set at construction', function() {
var feature = new _ol_Feature_({
var feature = new Feature({
geometry: point
});
expect(feature.getGeometry()).to.be(point);
});
it('gets any geometry set by setGeometry', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setGeometry(point);
expect(feature.getGeometry()).to.be(point);
@@ -133,7 +133,7 @@ describe('ol.Feature', function() {
describe('#set()', function() {
it('sets values', function() {
var feature = new _ol_Feature_({
var feature = new Feature({
a: 'first',
b: 'second'
});
@@ -143,7 +143,7 @@ describe('ol.Feature', function() {
it('can be used to set the geometry', function() {
var point = new Point([3, 4]);
var feature = new _ol_Feature_({
var feature = new Feature({
geometry: new Point([1, 2])
});
feature.set('geometry', point);
@@ -153,7 +153,7 @@ describe('ol.Feature', function() {
it('can be used to set attributes with arbitrary names', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.set('toString', 'string');
expect(feature.get('toString')).to.be('string');
@@ -174,13 +174,13 @@ describe('ol.Feature', function() {
var point = new Point([15, 30]);
it('sets the default geometry', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setGeometry(point);
expect(feature.get('geometry')).to.be(point);
});
it('replaces previous default geometry', function() {
var feature = new _ol_Feature_({
var feature = new Feature({
geometry: point
});
expect(feature.getGeometry()).to.be(point);
@@ -197,7 +197,7 @@ describe('ol.Feature', function() {
var point = new Point([15, 30]);
it('sets property where to to look at geometry', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setGeometry(point);
expect(feature.getGeometry()).to.be(point);
@@ -214,7 +214,7 @@ describe('ol.Feature', function() {
});
it('changes property listener', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setGeometry(point);
var point2 = new Point([1, 2]);
feature.set('altGeometry', point2);
@@ -227,7 +227,7 @@ describe('ol.Feature', function() {
});
it('can use a different geometry name', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setGeometryName('foo');
var point = new Point([10, 20]);
feature.setGeometry(point);
@@ -239,14 +239,14 @@ describe('ol.Feature', function() {
describe('#setId()', function() {
it('sets the feature identifier', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
expect(feature.getId()).to.be(undefined);
feature.setId('foo');
expect(feature.getId()).to.be('foo');
});
it('accepts a string or number', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setId('foo');
expect(feature.getId()).to.be('foo');
feature.setId(2);
@@ -254,7 +254,7 @@ describe('ol.Feature', function() {
});
it('dispatches the "change" event', function(done) {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.on('change', function() {
expect(feature.getId()).to.be('foo');
done();
@@ -271,24 +271,24 @@ describe('ol.Feature', function() {
};
it('returns undefined after construction', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
expect(feature.getStyleFunction()).to.be(undefined);
});
it('returns the function passed to setStyle', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setStyle(styleFunction);
expect(feature.getStyleFunction()).to.be(styleFunction);
});
it('does not get confused with user "styleFunction" property', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.set('styleFunction', 'foo');
expect(feature.getStyleFunction()).to.be(undefined);
});
it('does not get confused with "styleFunction" option', function() {
var feature = new _ol_Feature_({
var feature = new Feature({
styleFunction: 'foo'
});
expect(feature.getStyleFunction()).to.be(undefined);
@@ -305,21 +305,21 @@ describe('ol.Feature', function() {
};
it('accepts a single style', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setStyle(style);
var func = feature.getStyleFunction();
expect(func()).to.eql([style]);
});
it('accepts an array of styles', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setStyle([style]);
var func = feature.getStyleFunction();
expect(func()).to.eql([style]);
});
it('accepts a style function', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
function featureStyleFunction(resolution) {
return styleFunction(this, resolution);
}
@@ -329,14 +329,14 @@ describe('ol.Feature', function() {
});
it('accepts a layer style function', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setStyle(styleFunction);
expect(feature.getStyleFunction()).to.not.be(styleFunction);
expect(feature.getStyleFunction()(42)).to.be(42);
});
it('accepts null', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setStyle(style);
feature.setStyle(null);
expect(feature.getStyle()).to.be(null);
@@ -344,7 +344,7 @@ describe('ol.Feature', function() {
});
it('dispatches a change event', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
var spy = sinon.spy();
feature.on('change', spy);
feature.setStyle(style);
@@ -362,7 +362,7 @@ describe('ol.Feature', function() {
};
it('returns what is passed to setStyle', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
expect(feature.getStyle()).to.be(null);
@@ -378,7 +378,7 @@ describe('ol.Feature', function() {
});
it('does not get confused with "style" option to constructor', function() {
var feature = new _ol_Feature_({
var feature = new Feature({
style: 'foo'
});
@@ -386,7 +386,7 @@ describe('ol.Feature', function() {
});
it('does not get confused with user set "style" property', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.set('style', 'foo');
expect(feature.getStyle()).to.be(null);
@@ -397,7 +397,7 @@ describe('ol.Feature', function() {
describe('#clone', function() {
it('correctly clones features', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.setProperties({'fookey': 'fooval'});
feature.setId(1);
feature.setGeometryName('geom');
@@ -421,7 +421,7 @@ describe('ol.Feature', function() {
});
it('correctly clones features with no geometry and no style', function() {
var feature = new _ol_Feature_();
var feature = new Feature();
feature.set('fookey', 'fooval');
var clone = feature.clone();
@@ -435,7 +435,7 @@ describe('ol.Feature', function() {
it('dispatches a change event when geometry is set to null',
function() {
var feature = new _ol_Feature_({
var feature = new Feature({
geometry: new Point([0, 0])
});
var spy = sinon.spy();
@@ -451,12 +451,12 @@ describe('ol.Feature.createStyleFunction()', function() {
var style = new _ol_style_Style_();
it('creates a feature style function from a single style', function() {
var styleFunction = _ol_Feature_.createStyleFunction(style);
var styleFunction = Feature.createStyleFunction(style);
expect(styleFunction()).to.eql([style]);
});
it('creates a feature style function from an array of styles', function() {
var styleFunction = _ol_Feature_.createStyleFunction([style]);
var styleFunction = Feature.createStyleFunction([style]);
expect(styleFunction()).to.eql([style]);
});
@@ -464,13 +464,13 @@ describe('ol.Feature.createStyleFunction()', function() {
var original = function() {
return [style];
};
var styleFunction = _ol_Feature_.createStyleFunction(original);
var styleFunction = Feature.createStyleFunction(original);
expect(styleFunction).to.be(original);
});
it('throws on (some) unexpected input', function() {
expect(function() {
_ol_Feature_.createStyleFunction({bogus: 'input'});
Feature.createStyleFunction({bogus: 'input'});
}).to.throwException();
});