From d254de0844807e10227d3789c8cdd5dfc19fc257 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 18 Jun 2014 15:59:58 -0400 Subject: [PATCH] Switch to tape, add travis and coveralls --- .travis.yml | 10 ++++++++++ README.md | 6 +++++- package.json | 33 ++++++++++++++++++--------------- test/parse.test.js | 34 +++++++++++++++------------------- 4 files changed, 48 insertions(+), 35 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ffb9ff2 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index 32d2943..be4356b 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file + npm install vector-tile diff --git a/package.json b/package.json index 60f0a7a..a491b29 100644 --- a/package.json +++ b/package.json @@ -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" + } } diff --git a/test/parse.test.js b/test/parse.test.js index be083de..c576bbc 100644 --- a/test/parse.test.js +++ b/test/parse.test.js @@ -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(); }); });