Named exports from ol/obj

This commit is contained in:
Frederic Junod
2018-01-16 14:14:17 +01:00
parent 40f97eed85
commit 31e30d28b7
60 changed files with 174 additions and 183 deletions
+11 -13
View File
@@ -1,11 +1,11 @@
import _ol_obj_ from '../../../src/ol/obj.js';
import {assign, clear, isEmpty, getValues} from '../../../src/ol/obj.js';
describe('ol.obj.assign()', function() {
it('is an alias for Object.assign() where available', function() {
if (typeof Object.assign === 'function') {
expect(_ol_obj_.assign).to.be(Object.assign);
expect(assign).to.be(Object.assign);
}
});
@@ -21,7 +21,7 @@ describe('ol.obj.assign()', function() {
targetProp1: 'targetValue1'
};
const assigned = _ol_obj_.assign(target, source);
const assigned = assign(target, source);
expect(assigned).to.be(target);
expect(assigned.sourceProp1).to.be('sourceValue1');
expect(assigned.sourceProp2).to.be('sourceValue2');
@@ -30,13 +30,13 @@ describe('ol.obj.assign()', function() {
});
it('throws a TypeError with `undefined` as target', function() {
expect(_ol_obj_.assign).withArgs(undefined).to.throwException(function(e) {
expect(assign).withArgs(undefined).to.throwException(function(e) {
expect(e).to.be.a(TypeError);
});
});
it('throws a TypeError with `null` as target', function() {
expect(_ol_obj_.assign).withArgs(null).to.throwException(function(e) {
expect(assign).withArgs(null).to.throwException(function(e) {
expect(e).to.be.a(TypeError);
});
});
@@ -46,8 +46,6 @@ describe('ol.obj.assign()', function() {
describe('ol.obj.clear()', function() {
it('removes all properties from an object', function() {
const clear = _ol_obj_.clear;
const isEmpty = _ol_obj_.isEmpty;
expect(isEmpty(clear({foo: 'bar'}))).to.be(true);
expect(isEmpty(clear({foo: 'bar', num: 42}))).to.be(true);
expect(isEmpty(clear({}))).to.be(true);
@@ -59,8 +57,8 @@ describe('ol.obj.clear()', function() {
describe('ol.obj.getValues()', function() {
it('gets a list of property values from an object', function() {
expect(_ol_obj_.getValues({foo: 'bar', num: 42}).sort()).to.eql([42, 'bar']);
expect(_ol_obj_.getValues(null)).to.eql([]);
expect(getValues({foo: 'bar', num: 42}).sort()).to.eql([42, 'bar']);
expect(getValues(null)).to.eql([]);
});
});
@@ -68,10 +66,10 @@ describe('ol.obj.getValues()', function() {
describe('ol.obj.isEmpty()', function() {
it('checks if an object has any properties', function() {
expect(_ol_obj_.isEmpty({})).to.be(true);
expect(_ol_obj_.isEmpty(null)).to.be(true);
expect(_ol_obj_.isEmpty({foo: 'bar'})).to.be(false);
expect(_ol_obj_.isEmpty({foo: false})).to.be(false);
expect(isEmpty({})).to.be(true);
expect(isEmpty(null)).to.be(true);
expect(isEmpty({foo: 'bar'})).to.be(false);
expect(isEmpty({foo: false})).to.be(false);
});
});