diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-06-29 21:35:24 +0300 |
---|---|---|
committer | Mike Morris <mikemorris@users.noreply.github.com> | 2016-09-06 18:14:22 -0400 |
commit | edec56e6c55bdf992fb2d3f92d770db57c737e3e (patch) | |
tree | 51fd82feb9e7bffda6a653e15ecd331ee6095593 /platform/node/test/js | |
parent | d6f667a5e762ce1faec80bee774b805fe7ef5e11 (diff) | |
download | qtlocation-mapboxgl-edec56e6c55bdf992fb2d3f92d770db57c737e3e.tar.gz |
[node] switch to NodeRequest member fn callback
For (hopefully) better performance than creating a new v8::Context to
wrap each callback while still avoiding leaking memory with v8::FunctionTemplate.
Adds a JavaScript shim in front of module.exports.Map to wrap the
req.respond API internally and preserve the public callback-passing
API, while still exporting the correct prototype.
Diffstat (limited to 'platform/node/test/js')
-rw-r--r-- | platform/node/test/js/map.test.js | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js index 6ffbf3eb66..9300cac4e1 100644 --- a/platform/node/test/js/map.test.js +++ b/platform/node/test/js/map.test.js @@ -1,13 +1,15 @@ 'use strict'; var test = require('tape'); -var mbgl = require('../../../../lib/mapbox-gl-native'); +var mbgl = require('../../index'); var fs = require('fs'); var path = require('path'); var style = require('../fixtures/style.json'); test('Map', function(t) { - t.test('must be constructed with new', function(t) { + // This test is skipped because of the req.respond shim in index.js + // which will always call new mbgl.Map() + t.skip('must be constructed with new', function(t) { t.throws(function() { mbgl.Map(); }, /Use the new operator to create new Map objects/); @@ -87,6 +89,42 @@ test('Map', function(t) { t.end(); }); + t.test('instanceof mbgl.Map', function(t) { + var options = { + request: function() {}, + ratio: 1 + }; + + var map = new mbgl.Map(options); + + t.ok(map instanceof mbgl.Map); + t.equal(map.__proto__, mbgl.Map.prototype); + + var keys = Object.keys(mbgl.Map.prototype); + + t.deepEqual(keys, [ + 'load', + 'loaded', + 'render', + 'release', + 'addClass', + 'addSource', + 'addLayer', + 'removeLayer', + 'setLayoutProperty', + 'setPaintProperty', + 'setFilter', + 'dumpDebugLogs', + 'queryRenderedFeatures' + ]); + + for (var key in keys) { + t.equal(map[key], mbgl.Map.prototype[key]); + } + + t.end(); + }); + t.test('.load', function(t) { var options = { request: function() {}, |