Merge pull request #7780 from tschaub/named-exports

More named exports
This commit is contained in:
Tim Schaub
2018-02-08 04:02:31 -07:00
committed by GitHub
18 changed files with 80 additions and 87 deletions

View File

@@ -1,5 +1,5 @@
import {getUid} from '../../../src/ol/index.js';
import _ol_net_ from '../../../src/ol/net.js';
import {jsonp as requestJSONP} from '../../../src/ol/net.js';
describe('ol.net', function() {
@@ -54,11 +54,11 @@ describe('ol.net', function() {
});
it('appends callback param to url, cleans up after call', function(done) {
_ol_net_.jsonp('foo', createCallback('foo?callback=', done));
requestJSONP('foo', createCallback('foo?callback=', done));
});
it('appends correct callback param to a url with query', function(done) {
const callback = createCallback('http://foo/bar?baz&callback=', done);
_ol_net_.jsonp('http://foo/bar?baz', callback);
requestJSONP('http://foo/bar?baz', callback);
});
it('calls errback when jsonp is not executed, cleans up', function(done) {
head.appendChild = function(element) {
@@ -74,11 +74,11 @@ describe('ol.net', function() {
expect(removeChild.called).to.be(true);
done();
}
_ol_net_.jsonp('foo', callback, errback);
requestJSONP('foo', callback, errback);
});
it('accepts a custom callback param', function(done) {
const callback = createCallback('foo?mycallback=', done);
_ol_net_.jsonp('foo', callback, undefined, 'mycallback');
requestJSONP('foo', callback, undefined, 'mycallback');
});
});

View File

@@ -1,4 +1,4 @@
import _ol_size_ from '../../../src/ol/size.js';
import {hasArea, toSize, buffer as bufferSize, scale as scaleSize} from '../../../src/ol/size.js';
describe('ol.size', function() {
@@ -7,14 +7,14 @@ describe('ol.size', function() {
it('buffers a size', function() {
const size = [50, 75];
const bufferedSize = _ol_size_.buffer(size, 20);
const bufferedSize = bufferSize(size, 20);
expect(bufferedSize).to.eql([90, 115]);
});
it('reuses an existing array', function() {
const reuse = [0, 0];
const size = [50, 50];
const bufferedSize = _ol_size_.buffer(size, 20, reuse);
const bufferedSize = bufferSize(size, 20, reuse);
expect(bufferedSize).to.equal(reuse);
});
@@ -23,13 +23,13 @@ describe('ol.size', function() {
describe('hasArea()', function() {
it('determines if a size has a positive area', function() {
expect(_ol_size_.hasArea([50, 75])).to.equal(true);
expect(_ol_size_.hasArea([0, 75])).to.equal(false);
expect(_ol_size_.hasArea([50, 0])).to.equal(false);
expect(_ol_size_.hasArea([0, 0])).to.equal(false);
expect(_ol_size_.hasArea([-1, 75])).to.equal(false);
expect(_ol_size_.hasArea([50, -1])).to.equal(false);
expect(_ol_size_.hasArea([-1, -1])).to.equal(false);
expect(hasArea([50, 75])).to.equal(true);
expect(hasArea([0, 75])).to.equal(false);
expect(hasArea([50, 0])).to.equal(false);
expect(hasArea([0, 0])).to.equal(false);
expect(hasArea([-1, 75])).to.equal(false);
expect(hasArea([50, -1])).to.equal(false);
expect(hasArea([-1, -1])).to.equal(false);
});
});
@@ -38,14 +38,14 @@ describe('ol.size', function() {
it('scales a size and rounds the result', function() {
const size = [50, 75];
const scaledSize = _ol_size_.scale(size, 1.75);
const scaledSize = scaleSize(size, 1.75);
expect(scaledSize).to.eql([88, 131]);
});
it('reuses an existing array', function() {
const reuse = [0, 0];
const size = [50, 50];
const scaledSize = _ol_size_.scale(size, 1.75, reuse);
const scaledSize = scaleSize(size, 1.75, reuse);
expect(scaledSize).to.equal(reuse);
});
@@ -54,21 +54,21 @@ describe('ol.size', function() {
describe('toSize()', function() {
it('creates a size array from a number', function() {
const size = _ol_size_.toSize(512);
const size = toSize(512);
expect(size).to.eql([512, 512]);
});
it('reuses an existing array', function() {
const sizeArray = [0, 0];
const size = _ol_size_.toSize(512, sizeArray);
const size = toSize(512, sizeArray);
expect(size).to.equal(sizeArray);
});
it('returns a size array unaltered', function() {
const sizeArray = [512, 256];
let size = _ol_size_.toSize(sizeArray);
let size = toSize(sizeArray);
expect(size).to.equal(sizeArray);
size = _ol_size_.toSize(sizeArray, [0, 0]);
size = toSize(sizeArray, [0, 0]);
expect(size).to.equal(sizeArray);
});

View File

@@ -1,4 +1,3 @@
import _ol_net_ from '../../../../src/ol/net.js';
import BingMaps from '../../../../src/ol/source/BingMaps.js';
import _ol_tilecoord_ from '../../../../src/ol/tilecoord.js';
import Observable from '../../../../src/ol/Observable.js';
@@ -11,21 +10,18 @@ describe('ol.source.BingMaps', function() {
let source, tileGrid;
beforeEach(function(done) {
const olNetJsonp = _ol_net_.jsonp;
// mock ol.net.Jsonp (used in the ol.source.TileJSON constructor)
_ol_net_.jsonp = function(url, callback) {
const client = new XMLHttpRequest();
client.open('GET', 'spec/ol/data/bing_aerialwithlabels.json', true);
client.onload = function() {
callback(JSON.parse(client.responseText));
};
client.send();
};
source = new BingMaps({
imagerySet: 'AerialWithLabels',
key: ''
});
_ol_net_.jsonp = olNetJsonp;
const client = new XMLHttpRequest();
client.open('GET', 'spec/ol/data/bing_aerialwithlabels.json', true);
client.onload = function() {
source.handleImageryMetadataResponse(JSON.parse(client.responseText));
};
client.send();
const key = source.on('change', function() {
if (source.getState() === 'ready') {
Observable.unByKey(key);