[#35,all][m]: crude error catching for backends based on timeouts (best we can do with JSONP) - fixes #35.
* Show errors in UI * required some extensive refactoring to use done/fail on promise rather than then
This commit is contained in:
@@ -154,26 +154,32 @@
|
||||
var stub = sinon.stub($, 'ajax', function(options) {
|
||||
if (options.url.indexOf('schema.json') != -1) {
|
||||
return {
|
||||
then: function(callback) {
|
||||
done: function(callback) {
|
||||
callback(webstoreSchema);
|
||||
return this;
|
||||
},
|
||||
fail: function() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
then: function(callback) {
|
||||
done: function(callback) {
|
||||
callback(webstoreData);
|
||||
},
|
||||
fail: function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dataset.fetch().then(function(dataset) {
|
||||
dataset.fetch().done(function(dataset) {
|
||||
deepEqual(['__id__', 'date', 'geometry', 'amount'], dataset.get('headers'));
|
||||
equal(3, dataset.docCount)
|
||||
dataset.query().then(function(docList) {
|
||||
equal(3, docList.length)
|
||||
equal("2009-01-01", docList.models[0].get('date'));
|
||||
});
|
||||
// dataset.query().done(function(docList) {
|
||||
// equal(3, docList.length)
|
||||
// equal("2009-01-01", docList.models[0].get('date'));
|
||||
// });
|
||||
});
|
||||
$.ajax.restore();
|
||||
});
|
||||
@@ -255,21 +261,25 @@
|
||||
var partialUrl = 'jsonpdataproxy.appspot.com';
|
||||
if (options.url.indexOf(partialUrl) != -1) {
|
||||
return {
|
||||
then: function(callback) {
|
||||
done: function(callback) {
|
||||
callback(dataProxyData);
|
||||
return this;
|
||||
},
|
||||
fail: function() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dataset.fetch().then(function(dataset) {
|
||||
dataset.fetch().done(function(dataset) {
|
||||
deepEqual(['__id__', 'date', 'price'], dataset.get('headers'));
|
||||
equal(null, dataset.docCount)
|
||||
dataset.query().then(function(docList) {
|
||||
dataset.query().done(function(docList) {
|
||||
equal(10, docList.length)
|
||||
equal("1950-01", docList.models[0].get('date'));
|
||||
// needed only if not stubbing
|
||||
start();
|
||||
// needed only if not stubbing
|
||||
start();
|
||||
});
|
||||
});
|
||||
$.ajax.restore();
|
||||
|
||||
Reference in New Issue
Block a user