diff --git a/modules/core/file_fetcher.js b/modules/core/file_fetcher.js index a8196f14e..5d5d84a2f 100644 --- a/modules/core/file_fetcher.js +++ b/modules/core/file_fetcher.js @@ -61,8 +61,7 @@ export function coreFileFetcher() { if (!prom) { _inflight[url] = prom = fetch(url) .then(response => { - // fetch in PhantomJS tests may return ok=false and status=0 even if it's okay - if ((!response.ok && response.status !== 0) || !response.json) { + if (!response.ok || !response.json) { throw new Error(response.status + ' ' + response.statusText); } if (response.status === 204 || response.status === 205) return; // No Content, Reset Content diff --git a/test/spec/core/file_fetcher.js b/test/spec/core/file_fetcher.js index 5f82f2053..a209b5403 100644 --- a/test/spec/core/file_fetcher.js +++ b/test/spec/core/file_fetcher.js @@ -18,7 +18,7 @@ describe('iD.coreFileFetcher', function() { data.cache().test = { hello: 'world' }; var prom = data.get('test'); - // expect(prom).to.be.a('promise'); // these are polyfilled in phantomjs + expect(prom).to.be.a('promise'); prom .then(function(data) { expect(data).to.be.a('object'); @@ -28,8 +28,6 @@ describe('iD.coreFileFetcher', function() { .catch(function(err) { done(err); }); - - window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs }); it('returns a promise rejected if we can not get the data', function(done) { @@ -43,15 +41,13 @@ describe('iD.coreFileFetcher', function() { expect(/^Unknown data file/.test(err)).to.be.true; done(); }); - - window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs }); it('returns a promise to fetch data if we do not already have the data', function(done) { var files = { 'intro_graph': 'data/intro_graph.min.json' }; var data = iD.coreFileFetcher().assetPath('../dist/').fileMap(files); var prom = data.get('intro_graph'); - // expect(prom).to.be.a('promise'); // these are polyfilled in phantomjs + expect(prom).to.be.a('promise'); prom .then(function(data) { expect(data).to.be.a('object'); @@ -61,8 +57,6 @@ describe('iD.coreFileFetcher', function() { .catch(function(err) { done(err); }); - - window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs }); }); diff --git a/test/spec/core/locations.js b/test/spec/core/locations.js index 6fa094319..5931d36a6 100644 --- a/test/spec/core/locations.js +++ b/test/spec/core/locations.js @@ -49,8 +49,6 @@ describe('iD.coreLocations', function() { expect(/^nothing to do/.test(err)).to.be.true; done(); }); - - window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs }); it('resolves locationSets, assigning locationSetID', function(done) { @@ -69,8 +67,6 @@ describe('iD.coreLocations', function() { .catch(function(err) { done(err); }); - - window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs }); it('resolves locationSets, falls back to world locationSetID on errror', function(done) { @@ -89,8 +85,6 @@ describe('iD.coreLocations', function() { .catch(function(err) { done(err); }); - - window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs }); }); @@ -150,8 +144,6 @@ describe('iD.coreLocations', function() { .catch(function(err) { done(err); }); - - window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs }); }); diff --git a/test/spec/core/validator.js b/test/spec/core/validator.js index 5e1f5ed37..e9f2759c3 100644 --- a/test/spec/core/validator.js +++ b/test/spec/core/validator.js @@ -45,8 +45,6 @@ describe('iD.coreValidator', function () { .catch(function(err) { done(err); }); - - window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs }); }); diff --git a/test/spec/phantom.js b/test/spec/phantom.js deleted file mode 100644 index 2fe8360a6..000000000 --- a/test/spec/phantom.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('test some capabilities of PhantomJS', function () { - it('Array.from(Set)', function () { - var s = new Set([1,1]); - var result = Array.from(s); - expect(result).to.eql([1]); - }); - it('has ArrayBuffer.isView', function () { - expect(typeof ArrayBuffer.isView).to.eql('function'); - }); -}); diff --git a/test/spec/svg/data.js b/test/spec/svg/data.js index 6c2b70b2c..02a1e71d5 100644 --- a/test/spec/svg/data.js +++ b/test/spec/svg/data.js @@ -75,8 +75,6 @@ describe('iD.svgData', function () { '' + ''; - - // this is because PhantomJS hasn't implemented a proper File constructor function makeFile(contents, fileName, mimeType) { var blob = new Blob([contents], { type: mimeType }); blob.lastModifiedDate = new Date(); diff --git a/test/spec/ui/cmd.js b/test/spec/ui/cmd.js index 262d7bde4..3deb890f7 100644 --- a/test/spec/ui/cmd.js +++ b/test/spec/ui/cmd.js @@ -1,28 +1,18 @@ describe('iD.uiCmd', function () { var orig; var ua = navigator.userAgent; - var isPhantom = (navigator.userAgent.match(/PhantomJS/) !== null); var uaMock = function () { return ua; }; beforeEach(function() { /* eslint-disable no-global-assign */ /* mock userAgent */ - if (isPhantom) { - orig = navigator; - navigator = Object.create(orig, { userAgent: { get: uaMock }}); - } else { - orig = navigator.__lookupGetter__('userAgent'); - navigator.__defineGetter__('userAgent', uaMock); - } + orig = navigator.__lookupGetter__('userAgent'); + navigator.__defineGetter__('userAgent', uaMock); }); afterEach(function() { /* restore userAgent */ - if (isPhantom) { - navigator = orig; - } else { - navigator.__defineGetter__('userAgent', orig); - } + navigator.__defineGetter__('userAgent', orig); /* eslint-enable no-global-assign */ });