mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
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
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user