Declare global
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
goog.provide('ol.test.net');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.net');
|
||||
|
||||
|
||||
describe('ol.net', function() {
|
||||
|
||||
var global = ol.global;
|
||||
|
||||
describe('jsonp()', function() {
|
||||
var head = ol.global.document.getElementsByTagName('head')[0];
|
||||
var head = global.document.getElementsByTagName('head')[0];
|
||||
var origAppendChild = head.appendChild;
|
||||
var origCreateElement = document.createElement;
|
||||
var origSetTimeout = ol.global.setTimeout;
|
||||
var origSetTimeout = global.setTimeout;
|
||||
var key, removeChild;
|
||||
|
||||
function createCallback(url, done) {
|
||||
@@ -29,7 +31,7 @@ describe('ol.net', function() {
|
||||
if (arg == 'script') {
|
||||
return element;
|
||||
} else {
|
||||
return origCreateElement.apply(ol.global.document, arguments);
|
||||
return origCreateElement.apply(global.document, arguments);
|
||||
}
|
||||
};
|
||||
head.appendChild = function(el) {
|
||||
@@ -38,13 +40,13 @@ describe('ol.net', function() {
|
||||
removeChild: removeChild
|
||||
};
|
||||
origSetTimeout(function() {
|
||||
ol.global[key](element.src);
|
||||
global[key](element.src);
|
||||
}, 0);
|
||||
} else {
|
||||
origAppendChild.apply(head, arguments);
|
||||
}
|
||||
};
|
||||
ol.global.setTimeout = function(fn, time) {
|
||||
global.setTimeout = function(fn, time) {
|
||||
origSetTimeout(fn, 100);
|
||||
};
|
||||
});
|
||||
@@ -52,7 +54,7 @@ describe('ol.net', function() {
|
||||
afterEach(function() {
|
||||
document.createElement = origCreateElement;
|
||||
head.appendChild = origAppendChild;
|
||||
ol.global.setTimeout = origSetTimeout;
|
||||
global.setTimeout = origSetTimeout;
|
||||
});
|
||||
|
||||
it('appends callback param to url, cleans up after call', function(done) {
|
||||
@@ -72,7 +74,7 @@ describe('ol.net', function() {
|
||||
expect.fail();
|
||||
}
|
||||
function errback() {
|
||||
expect(ol.global[key]).to.be(undefined);
|
||||
expect(global[key]).to.be(undefined);
|
||||
expect(removeChild.called).to.be(true);
|
||||
done();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user