summaryrefslogtreecommitdiff
path: root/platform/node/test/js/request.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'platform/node/test/js/request.test.js')
-rw-r--r--platform/node/test/js/request.test.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/platform/node/test/js/request.test.js b/platform/node/test/js/request.test.js
index 9715633e39..ec2b084f4e 100644
--- a/platform/node/test/js/request.test.js
+++ b/platform/node/test/js/request.test.js
@@ -66,3 +66,51 @@ var test = require('tape');
});
});
});
+
+test(`render reports an error if the request function throws an exception`, function(t) {
+ var map = new mbgl.Map({
+ request: function() {
+ throw new Error('message');
+ }
+ });
+ map.load(mockfs.style_vector);
+ map.render({ zoom: 16 }, function(err, pixels) {
+ t.assert(err);
+ t.assert(/message/.test(err.message));
+ t.assert(!pixels);
+ t.end();
+ });
+});
+
+test(`render ignores request functions throwing an exception after calling the callback`, function(t) {
+ var map = new mbgl.Map({
+ request: function(req, callback) {
+ var data = mockfs.dataForRequest(req);
+ callback(null, { data: data });
+ throw new Error('message');
+ }
+ });
+ map.load(mockfs.style_vector);
+ map.render({ zoom: 16 }, function(err, pixels) {
+ t.error(err);
+ t.assert(pixels);
+ t.end();
+ });
+});
+
+test(`render ignores request functions calling the callback a second time`, function(t) {
+ var map = new mbgl.Map({
+ request: function(req, callback) {
+ var data = mockfs.dataForRequest(req);
+ callback(null, { data: data });
+ callback(null, { data: data });
+ }
+ });
+ map.load(mockfs.style_vector);
+ map.render({ zoom: 16 }, function(err, pixels) {
+ t.error(err);
+ t.assert(pixels);
+ t.end();
+ });
+});
+