Permalink
Browse files

move to mocha for tests and update them

  • Loading branch information...
Dane Springmeyer
Dane Springmeyer committed Apr 12, 2012
1 parent 81ca3b5 commit 66487d44f5853e5782954ff586ed2860420ff1ed
View
@@ -30,15 +30,15 @@ uninstall:
@node-waf uninstall
test-tmp:
- @rm -rf tests/tmp
- @mkdir -p tests/tmp
+ @rm -rf test/tmp
+ @mkdir -p test/tmp
ifndef only
test: test-tmp
- @PATH=./node_modules/expresso/bin:${PATH} && NODE_PATH=./lib:$NODE_PATH expresso
+ @PATH=./node_modules/mocha/bin:${PATH} && NODE_PATH=./lib:$NODE_PATH mocha -R spec
else
test: test-tmp
- @PATH=./node_modules/expresso/bin:${PATH} && NODE_PATH=./lib:$NODE_PATH expresso test/${only}.test.js
+ @PATH=./node_modules/mocha/bin:${PATH} && NODE_PATH=./lib:$NODE_PATH mocha -R spec test/${only}.test.js
endif
fix:
View
@@ -1,36 +1,54 @@
var mapnik = require('mapnik');
+var assert = require('assert');
-exports['test color creation'] = function(beforeExit, assert) {
- // no 'new' keyword
- assert.throws(function() { mapnik.Color(); });
+describe('mapnik.Color', function() {
+ it('should throw with invalid usage', function() {
+ // no 'new' keyword
+ assert.throws(function() { mapnik.Color(); });
+ // invalid args
+ assert.throws(function() { new mapnik.Color(); });
+ assert.throws(function() { new mapnik.Color(1); });
+ assert.throws(function() { new mapnik.Color('foo'); });
+ });
- // invalid args
- assert.throws(function() { new mapnik.Color(); });
- assert.throws(function() { new mapnik.Color(1); });
- assert.throws(function() { new mapnik.Color('foo'); });
+ it('should be green via keyword', function() {
+ var c = new mapnik.Color('green');
+ assert.equal(c.r, 0);
+ assert.equal(c.g, 128);
+ assert.equal(c.b, 0);
+ assert.equal(c.a, 255);
+ assert.equal(c.hex(), '#008000');
+ assert.equal(c.toString(), 'rgb(0,128,0)');
+ });
- var c = new mapnik.Color('green');
- assert.equal(c.r, 0);
- assert.equal(c.g, 128);
- assert.equal(c.b, 0);
- assert.equal(c.a, 255);
- assert.equal(c.hex(), '#008000');
- assert.equal(c.toString(), 'rgb(0,128,0)');
- c = new mapnik.Color(0, 128, 0);
- assert.equal(c.r, 0);
- assert.equal(c.g, 128);
- assert.equal(c.b, 0);
- assert.equal(c.a, 255);
- assert.equal(c.hex(), '#008000');
- assert.equal(c.toString(), 'rgb(0,128,0)');
+ it('should be gray via rgb', function() {
+ var c = new mapnik.Color(0, 128, 0);
+ assert.equal(c.r, 0);
+ assert.equal(c.g, 128);
+ assert.equal(c.b, 0);
+ assert.equal(c.a, 255);
+ assert.equal(c.hex(), '#008000');
+ assert.equal(c.toString(), 'rgb(0,128,0)');
+ });
- c = new mapnik.Color(0, 128, 0, 255);
- assert.equal(c.r, 0);
- assert.equal(c.g, 128);
- assert.equal(c.b, 0);
- assert.equal(c.a, 255);
- assert.equal(c.hex(), '#008000');
- assert.equal(c.toString(), 'rgb(0,128,0)');
+ it('should be gray via rgba', function() {
+ var c = new mapnik.Color(0, 128, 0, 255);
+ assert.equal(c.r, 0);
+ assert.equal(c.g, 128);
+ assert.equal(c.b, 0);
+ assert.equal(c.a, 255);
+ assert.equal(c.hex(), '#008000');
+ assert.equal(c.toString(), 'rgb(0,128,0)');
+ });
-};
+ it('should be gray via rgba %', function() {
+ var c = new mapnik.Color('rgba(0%,50%,0%,1)');
+ assert.equal(c.r, 0);
+ assert.equal(c.g, 128);
+ assert.equal(c.b, 0);
+ assert.equal(c.a, 255);
+ assert.equal(c.hex(), '#008000');
+ assert.equal(c.toString(), 'rgb(0,128,0)');
+ });
+});
View
@@ -1,30 +1,57 @@
var mapnik = require('mapnik');
+var assert = require('assert');
var fs = require('fs');
-exports['test constants'] = function(beforeExit, assert) {
- assert.ok(mapnik.settings);
- assert.ok(mapnik.settings.paths);
- assert.ok(mapnik.settings.paths.fonts.length);
- assert.ok(fs.statSync(mapnik.settings.paths.fonts));
- assert.ok(mapnik.settings.paths.input_plugins.length);
- assert.ok(fs.statSync(mapnik.settings.paths.input_plugins));
-
- // reloading the default plugins path should return false as no more plugins are registered
- assert.ok(!mapnik.register_datasources(mapnik.settings.paths.input_plugins));
-
- /* has version info */
- assert.ok(mapnik.versions);
- assert.ok(mapnik.versions.node);
- assert.ok(mapnik.versions.v8);
- assert.ok(mapnik.versions.mapnik);
- assert.ok(mapnik.versions.mapnik_number);
- assert.ok(mapnik.versions.boost);
- assert.ok(mapnik.versions.boost_number);
-
- assert.ok(mapnik.Geometry.Point,1);
- assert.ok(mapnik.Geometry.LineString,2);
- assert.ok(mapnik.Geometry.Polygon,3);
-
- // make sure we have some
- assert.ok(mapnik.datasources().length > 0);
-};
+describe('mapnik constants', function() {
+ it('should have valid settings', function() {
+ assert.ok(mapnik.settings);
+ assert.ok(mapnik.settings.paths);
+ assert.ok(mapnik.settings.paths.fonts.length);
+ assert.ok(fs.statSync(mapnik.settings.paths.fonts));
+ assert.ok(mapnik.settings.paths.input_plugins.length);
+ assert.ok(fs.statSync(mapnik.settings.paths.input_plugins));
+
+ // reloading the default plugins path should return false as no more plugins are registered
+ assert.ok(!mapnik.register_datasources(mapnik.settings.paths.input_plugins));
+
+ /* has version info */
+ assert.ok(mapnik.versions);
+ assert.ok(mapnik.versions.node);
+ assert.ok(mapnik.versions.v8);
+ assert.ok(mapnik.versions.mapnik);
+ assert.ok(mapnik.versions.mapnik_number);
+ assert.ok(mapnik.versions.boost);
+ assert.ok(mapnik.versions.boost_number);
+
+ assert.ok(mapnik.Geometry.Point, 1);
+ assert.ok(mapnik.Geometry.LineString, 2);
+ assert.ok(mapnik.Geometry.Polygon, 3);
+
+ // make sure we have some
+ assert.ok(mapnik.datasources().length > 0);
+ });
+
+ it('should have valid version info', function() {
+ /* has version info */
+ assert.ok(mapnik.versions);
+ assert.ok(mapnik.versions.node);
+ assert.ok(mapnik.versions.v8);
+ assert.ok(mapnik.versions.mapnik);
+ assert.ok(mapnik.versions.mapnik_number);
+ assert.ok(mapnik.versions.boost);
+ assert.ok(mapnik.versions.boost_number);
+
+ assert.ok(mapnik.Geometry.Point, 1);
+ assert.ok(mapnik.Geometry.LineString, 2);
+ assert.ok(mapnik.Geometry.Polygon, 3);
+
+ // make sure we have some
+ assert.ok(mapnik.datasources().length > 0);
+ });
+
+ it('should expose Geometry enums', function() {
+ assert.ok(mapnik.Geometry.Point, 1);
+ assert.ok(mapnik.Geometry.LineString, 2);
+ assert.ok(mapnik.Geometry.Polygon, 3);
+ });
+});
Oops, something went wrong.

0 comments on commit 66487d4

Please sign in to comment.