Switch to tape, add travis and coveralls

This commit is contained in:
Tom MacWright 2014-06-18 15:59:58 -04:00
parent ea7331fec4
commit d254de0844
4 changed files with 48 additions and 35 deletions

10
.travis.yml Normal file
View File

@ -0,0 +1,10 @@
language: node_js
node_js:
- "0.8"
- "0.10"
before_install:
- npm install -g npm@~1.4.6
script:
- npm install
- npm test
- npm run cov

View File

@ -1,3 +1,7 @@
# vector-tile-js
[![build status](https://secure.travis-ci.org/mapbox/vector-tile-js.png)](http://travis-ci.org/mapbox/vector-tile-js) [![Coverage Status](https://coveralls.io/repos/mapbox/vector-tile-js/badge.png)](https://coveralls.io/r/mapbox/vector-tile-js)
This library reads vector tiles and allows access to the layers and features.
## Example
@ -26,4 +30,4 @@ landuse.feature(0);
To install:
npm install vector-tile
npm install vector-tile

View File

@ -1,17 +1,20 @@
{
"name": "vector-tile",
"description": "Parses vector tiles",
"repository": "https://github.com/mapbox/vector-tile-js.git",
"version": "0.0.1",
"license": "BSD",
"main": "./lib/vectortile",
"dependencies": {
"pbf": "~0.0.1"
},
"devDependencies": {
"mocha": "~1.18.2"
},
"scripts": {
"test": "mocha -R spec"
}
"name": "vector-tile",
"description": "Parses vector tiles",
"repository": "https://github.com/mapbox/vector-tile-js.git",
"version": "0.0.1",
"license": "BSD",
"main": "./lib/vectortile",
"dependencies": {
"pbf": "~0.0.1"
},
"devDependencies": {
"tape": "~2.13.3",
"istanbul": "~0.2.11",
"coveralls": "~2.10.0"
},
"scripts": {
"test": "tape test/parse.test.js",
"cov": "istanbul cover ./node_modules/.bin/tape test/parse.test.js && coveralls < ./coverage/lcov.info"
}
}

View File

@ -1,40 +1,36 @@
var assert = require('assert');
var fs = require('fs');
var test = require('tape'),
fs = require('fs'),
VectorTile = require('..');
var VectorTile = require('..');
test('parsing vector tiles', function(t) {
var data = fs.readFileSync('./test/fixtures/14-8801-5371.vector.pbf');
describe('parsing vector tiles', function() {
var data;
before(function() {
data = fs.readFileSync('./test/fixtures/14-8801-5371.vector.pbf');
});
it('should have all layers', function() {
t.test('should have all layers', function(t) {
var tile = new VectorTile(data);
assert.deepEqual(Object.keys(tile.layers), [
t.deepEqual(Object.keys(tile.layers), [
'landuse', 'waterway', 'water', 'barrier_line', 'building',
'landuse_overlay', 'tunnel', 'road', 'bridge', 'place_label',
'water_label', 'poi_label', 'road_label', 'waterway_label' ]);
// console.warn(tile.layers.poi_label);
t.end();
});
it('should extract the tags of a feature', function() {
t.test('should extract the tags of a feature', function(t) {
var tile = new VectorTile(data);
assert.equal(tile.layers.poi_label.length, 558);
t.equal(tile.layers.poi_label.length, 558);
var park = tile.layers.poi_label.feature(11);
assert.equal(park.name, 'Mauerpark');
assert.equal(park.type, 'Park');
t.equal(park.name, 'Mauerpark');
t.equal(park.type, 'Park');
// Check point geometry
assert.deepEqual(park.loadGeometry(), [ [ { x: 3898, y: 1731 } ] ]);
t.deepEqual(park.loadGeometry(), [ [ { x: 3898, y: 1731 } ] ]);
// Check line geometry
assert.deepEqual(tile.layers.road.feature(656).loadGeometry(), [ [ { x: 1988, y: 306 }, { x: 1808, y: 321 }, { x: 1506, y: 347 } ] ]);
t.deepEqual(tile.layers.road.feature(656).loadGeometry(), [ [ { x: 1988, y: 306 }, { x: 1808, y: 321 }, { x: 1506, y: 347 } ] ]);
t.end();
});
});