Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move to mocha for tests and update them
- Loading branch information
Dane Springmeyer
committed
Apr 12, 2012
1 parent
81ca3b5
commit 66487d4
Showing
20 changed files
with
914 additions
and
937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,36 +1,54 @@ | |||
var mapnik = require('mapnik'); | var mapnik = require('mapnik'); | ||
var assert = require('assert'); | |||
|
|
||
exports['test color creation'] = function(beforeExit, assert) { | describe('mapnik.Color', function() { | ||
// no 'new' keyword | it('should throw with invalid usage', function() { | ||
assert.throws(function() { mapnik.Color(); }); | // 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 | it('should be green via keyword', function() { | ||
assert.throws(function() { new mapnik.Color(); }); | var c = new mapnik.Color('green'); | ||
assert.throws(function() { new mapnik.Color(1); }); | assert.equal(c.r, 0); | ||
assert.throws(function() { new mapnik.Color('foo'); }); | 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); | it('should be gray via rgb', function() { | ||
assert.equal(c.r, 0); | var c = new mapnik.Color(0, 128, 0); | ||
assert.equal(c.g, 128); | assert.equal(c.r, 0); | ||
assert.equal(c.b, 0); | assert.equal(c.g, 128); | ||
assert.equal(c.a, 255); | assert.equal(c.b, 0); | ||
assert.equal(c.hex(), '#008000'); | assert.equal(c.a, 255); | ||
assert.equal(c.toString(), 'rgb(0,128,0)'); | assert.equal(c.hex(), '#008000'); | ||
assert.equal(c.toString(), 'rgb(0,128,0)'); | |||
}); | |||
|
|
||
c = new mapnik.Color(0, 128, 0, 255); | it('should be gray via rgba', function() { | ||
assert.equal(c.r, 0); | var c = new mapnik.Color(0, 128, 0, 255); | ||
assert.equal(c.g, 128); | assert.equal(c.r, 0); | ||
assert.equal(c.b, 0); | assert.equal(c.g, 128); | ||
assert.equal(c.a, 255); | assert.equal(c.b, 0); | ||
assert.equal(c.hex(), '#008000'); | assert.equal(c.a, 255); | ||
assert.equal(c.toString(), 'rgb(0,128,0)'); | 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)'); | |||
}); | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,30 +1,57 @@ | |||
var mapnik = require('mapnik'); | var mapnik = require('mapnik'); | ||
var assert = require('assert'); | |||
var fs = require('fs'); | var fs = require('fs'); | ||
|
|
||
exports['test constants'] = function(beforeExit, assert) { | describe('mapnik constants', function() { | ||
assert.ok(mapnik.settings); | it('should have valid settings', function() { | ||
assert.ok(mapnik.settings.paths); | assert.ok(mapnik.settings); | ||
assert.ok(mapnik.settings.paths.fonts.length); | assert.ok(mapnik.settings.paths); | ||
assert.ok(fs.statSync(mapnik.settings.paths.fonts)); | assert.ok(mapnik.settings.paths.fonts.length); | ||
assert.ok(mapnik.settings.paths.input_plugins.length); | assert.ok(fs.statSync(mapnik.settings.paths.fonts)); | ||
assert.ok(fs.statSync(mapnik.settings.paths.input_plugins)); | 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)); | // 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); | /* has version info */ | ||
assert.ok(mapnik.versions.node); | assert.ok(mapnik.versions); | ||
assert.ok(mapnik.versions.v8); | assert.ok(mapnik.versions.node); | ||
assert.ok(mapnik.versions.mapnik); | assert.ok(mapnik.versions.v8); | ||
assert.ok(mapnik.versions.mapnik_number); | assert.ok(mapnik.versions.mapnik); | ||
assert.ok(mapnik.versions.boost); | assert.ok(mapnik.versions.mapnik_number); | ||
assert.ok(mapnik.versions.boost_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.Point, 1); | ||
assert.ok(mapnik.Geometry.Polygon,3); | assert.ok(mapnik.Geometry.LineString, 2); | ||
|
assert.ok(mapnik.Geometry.Polygon, 3); | ||
// make sure we have some |
|
||
assert.ok(mapnik.datasources().length > 0); | // 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.