From e7ad3845f94069cff7bb6804afe3595b11ed85cb Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 16 Aug 2021 15:23:31 -0400 Subject: [PATCH] Fix file fetcher tests that touch the intro_graph - Before it wasn't actually loading the intro graph because assetPath not set - The test for Three Rivers City Hall was using the wrong nodeid - All these test errors were being ignored because of the use of .finally(done) - To actually make an error happen, we can call `done(err)` with the Error --- test/spec/core/file_fetcher.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/test/spec/core/file_fetcher.js b/test/spec/core/file_fetcher.js index 47aec5888..5f82f2053 100644 --- a/test/spec/core/file_fetcher.js +++ b/test/spec/core/file_fetcher.js @@ -1,14 +1,5 @@ describe('iD.coreFileFetcher', function() { - before(function() { - iD.fileFetcher.cache().test = { hello: 'world' }; - }); - - after(function() { - delete iD.fileFetcher.cache().test; - }); - - describe('#fileMap', function() { it('gets the fileMap', function() { var data = iD.coreFileFetcher(); @@ -24,44 +15,52 @@ describe('iD.coreFileFetcher', function() { describe('#get', function() { it('returns a promise resolved if we already have the data', function(done) { var data = iD.coreFileFetcher(); + data.cache().test = { hello: 'world' }; + var prom = data.get('test'); // expect(prom).to.be.a('promise'); // these are polyfilled in phantomjs prom .then(function(data) { expect(data).to.be.a('object'); expect(data.hello).to.eql('world'); + done(); }) - .finally(done); + .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) { - var data = iD.coreFileFetcher(); + var data = iD.coreFileFetcher().assetPath('../dist/'); var prom = data.get('wat'); prom .then(function(data) { - throw new Error('We were not supposed to get data but did: ' + data); + done(new Error('We were not supposed to get data but did: ' + data)); }) .catch(function(err) { expect(/^Unknown data file/.test(err)).to.be.true; - }) - .finally(done); + 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().fileMap(files); + 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 prom .then(function(data) { expect(data).to.be.a('object'); - expect(data.n1.tags.name).to.eql('Three Rivers City Hall'); + expect(data.n2061.tags.name).to.eql('Three Rivers City Hall'); + done(); }) - .finally(done); + .catch(function(err) { + done(err); + }); window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs });