Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

finish the port from expresso to mocha

  • Loading branch information...
commit 87e8037b9aeb5ad56399dbbde26705944412b347 1 parent e239e81
@springmeyer springmeyer authored
View
29 test/grid.test.js
@@ -28,38 +28,40 @@ describe('mapnik.Grid ', function() {
assert.equal(grid.encodeSync().length, v.encodeSync().length);
});
- it('should be painted after rendering', function(done) {
+ it('should not be painted after rendering', function(done) {
var grid_blank = new mapnik.Grid(4, 4);
assert.equal(grid_blank.painted(), false);
assert.equal(grid_blank.background, undefined);
var m = new mapnik.Map(4, 4);
var l = new mapnik.Layer('test');
m.add_layer(l);
-
m.render(grid_blank, {layer: 0},function(err,grid_blank) {
assert.equal(grid_blank.painted(), false);
+ // TODO - expose grid background
assert.equal(grid_blank.background, undefined);
+ done();
});
+ });
- var grid_blank2 = new mapnik.Grid(4, 4);
- assert.equal(grid_blank2.painted(), false);
- assert.equal(grid_blank2.background, undefined);
+ it('should be have background applied after rendering', function(done) {
- var m2 = new mapnik.Map(4, 4);
+ var grid_blank = new mapnik.Grid(4, 4);
+ var m = new mapnik.Map(4, 4);
var l = new mapnik.Layer('test');
- m2.add_layer(l);
-
- m2.background = new mapnik.Color('green');
- m2.render(grid_blank2, {layer: 0},function(err,grid_blank2) {
- assert.equal(grid_blank2.painted(), false);
+ m.add_layer(l);
+ m.background = new mapnik.Color('green');
+ m.render(grid_blank, {layer: 0},function(err,grid_blank2) {
+ assert.equal(grid_blank.painted(), false);
+ // TODO - expose grid background
//assert.ok(grid_blank2.background);
+ done();
});
+ });
-
+ it('should be painted after rendering2', function(done) {
var grid_blank3 = new mapnik.Grid(4, 4);
assert.equal(grid_blank3.painted(), false);
assert.equal(grid_blank3.background, undefined);
-
var m3 = new mapnik.Map(4, 4);
var s = '<Map>';
s += '<Style name="points">';
@@ -69,7 +71,6 @@ describe('mapnik.Grid ', function() {
s += '</Style>';
s += '</Map>';
m3.fromStringSync(s);
-
var mem_datasource = new mapnik.MemoryDatasource({'extent': '-180,-90,180,90'});
mem_datasource.add({ 'x': 0, 'y': 0 });
mem_datasource.add({ 'x': 1, 'y': 1 });
View
1  test/grid_view.test.js
@@ -31,7 +31,6 @@ describe('mapnik.GridView ', function() {
};
var grid = new mapnik.Grid(map.width, map.height, {key: '__id__'});
map.render(grid, options, function(err, grid) {
-
var view = grid.view(0, 0, 256, 256);
assert.equal(view.isSolid(), false);
// hit alaska (USA is id 207)
View
8 test/image.test.js
@@ -38,7 +38,7 @@ describe('mapnik.Image ', function() {
assert.equal(im.encodeSync().length, im2.encodeSync().length);
});
- it('should be painted after rendering', function(done) {
+ it('should not be painted after rendering', function(done) {
var im_blank = new mapnik.Image(4, 4);
assert.equal(im_blank.painted(), false);
assert.equal(im_blank.background, undefined);
@@ -48,8 +48,11 @@ describe('mapnik.Image ', function() {
m.render(im_blank, {},function(err,im_blank) {
assert.equal(im_blank.painted(), false);
assert.equal(im_blank.background, undefined);
+ done();
});
+ });
+ it('should have background set after rendering', function(done) {
var im_blank2 = new mapnik.Image(4, 4);
assert.equal(im_blank2.painted(), false);
assert.equal(im_blank2.background, undefined);
@@ -60,8 +63,11 @@ describe('mapnik.Image ', function() {
m2.render(im_blank2, {},function(err,im_blank2) {
assert.equal(im_blank2.painted(), false);
assert.ok(im_blank2.background);
+ done();
});
+ });
+ it('should be painted after rendering', function(done) {
var im_blank3 = new mapnik.Image(4, 4);
assert.equal(im_blank3.painted(), false);
View
102 test/render_grid.test.js
@@ -7,9 +7,37 @@ var reference = fs.readFileSync('./test/support/grid2.json', 'utf8');
var reference_view = fs.readFileSync('./test/support/grid_view.json', 'utf8');
describe('mapnik grid rendering ', function() {
- it('should match expected output (sync rendering)', function() {
- var map_grid = new mapnik.Map(256, 256);
- map_grid.load(stylesheet, {strict: true}, function(err,map) {
+
+ it('should match expected output (sync rendering)', function(done) {
+ var map = new mapnik.Map(256, 256);
+ map.loadSync(stylesheet, {strict: true});
+ map.zoomAll();
+ var grid = new mapnik.Grid(map.width, map.height, {key: '__id__'});
+ var options = {'layer': 0,
+ 'fields': ['NAME']
+ };
+ map.render(grid, options, function(err, grid) {
+ var grid_utf = grid.encodeSync('utf', {resolution: 4});
+ //fs.writeFileSync('./ref.json',JSON.stringify(grid_utf))
+ assert.equal(JSON.stringify(grid_utf), reference);
+ // pull an identical view and compare it to original grid
+ var gv = grid.view(0, 0, 256, 256);
+ var gv_utf = gv.encodeSync('utf', {resolution: 4});
+ assert.equal(JSON.stringify(gv_utf), reference);
+ // pull a subsetted view (greenland basically)
+ var gv2 = grid.view(64, 64, 64, 64);
+ assert.equal(gv2.width(), 64);
+ assert.equal(gv2.height(), 64);
+ var gv_utf2 = gv2.encodeSync('utf', {resolution: 4});
+ //fs.writeFileSync('./test/support/grid_view.json',JSON.stringify(gv_utf2),'utf8')
+ assert.equal(JSON.stringify(gv_utf2), reference_view);
+ done();
+ });
+ });
+
+ it('should match expected output (async rendering)', function(done) {
+ var map = new mapnik.Map(256, 256);
+ map.load(stylesheet, {strict: true}, function(err,map) {
if (err) throw err;
map.zoomAll();
var grid = new mapnik.Grid(map.width, map.height, {key: '__id__'});
@@ -19,29 +47,38 @@ describe('mapnik grid rendering ', function() {
};
map.render(grid, options, function(err, grid) {
assert.ok(!err);
- grid_utf = grid.encodeSync('utf', {resolution: 4});
- //fs.writeFileSync('./ref.json',JSON.stringify(grid_utf))
- assert.equal(JSON.stringify(grid_utf), reference);
- // pull an identical view and compare it to original grid
- var gv = grid.view(0, 0, 256, 256);
- gv_utf = gv.encodeSync('utf', {resolution: 4});
- assert.equal(JSON.stringify(gv_utf), reference);
+ grid.encode('utf', {resolution: 4}, function(err,utf) {
+ assert.equal(JSON.stringify(utf), reference);
+ done();
+ });
+ });
+ });
+ });
- // pull a subsetted view (greenland basically)
- var gv2 = grid.view(64, 64, 64, 64);
- assert.equal(gv2.width(), 64);
- assert.equal(gv2.height(), 64);
- gv_utf2 = gv2.encodeSync('utf', {resolution: 4});
- //fs.writeFileSync('./test/support/grid_view.json',JSON.stringify(gv_utf2),'utf8')
- assert.equal(JSON.stringify(gv_utf2), reference_view);
- done();
+ it('should match expected output (async rendering view)', function(done) {
+ var map = new mapnik.Map(256, 256);
+ map.load(stylesheet, {strict: true}, function(err,map) {
+ if (err) throw err;
+ map.zoomAll();
+ var grid = new mapnik.Grid(map.width, map.height, {key: '__id__'});
+
+ var options = {'layer': 0,
+ 'fields': ['NAME']
+ };
+ map.render(grid, options, function(err, grid) {
+ assert.ok(!err);
+ var gv = grid.view(0, 0, 256, 256);
+ gv.encode('utf', {resolution: 4}, function(err,gv_utf1) {
+ assert.equal(JSON.stringify(gv_utf1), reference);
+ done()
+ });
});
});
});
- it('should match expected output (async rendering)', function() {
- var map_grid = new mapnik.Map(256, 256);
- map_grid.load(stylesheet, {strict: true}, function(err,map) {
+ it('should match expected output (async rendering view subsetted)', function(done) {
+ var map = new mapnik.Map(256, 256);
+ map.load(stylesheet, {strict: true}, function(err,map) {
if (err) throw err;
map.zoomAll();
var grid = new mapnik.Grid(map.width, map.height, {key: '__id__'});
@@ -51,23 +88,16 @@ describe('mapnik grid rendering ', function() {
};
map.render(grid, options, function(err, grid) {
assert.ok(!err);
- grid.encode('utf', {resolution: 4}, function(utf) {
- assert.equal(JSON.stringify(utf), reference);
- // pull an identical view and compare it to original grid
- var gv = grid.view(0, 0, 256, 256);
- gv_utf = gv.encode('utf', {resolution: 4}, function(utf) {
- assert.equal(JSON.stringify(utf), reference);
- // pull a subsetted view (greenland basically)
- var gv2 = grid.view(64, 64, 64, 64);
- assert.equal(gv2.width(), 64);
- assert.equal(gv2.height(), 64);
- gv_utf2 = gv2.encode('utf', {resolution: 4}, function(utf) {
- assert.equal(JSON.stringify(gv_utf2), reference_view);
- done();
- });
- });
+ // pull a subsetted view (greenland basically)
+ var gv2 = grid.view(64, 64, 64, 64);
+ assert.equal(gv2.width(), 64);
+ assert.equal(gv2.height(), 64);
+ gv2.encode('utf', {resolution: 4}, function(err,gv_utf2) {
+ assert.equal(JSON.stringify(gv_utf2), reference_view);
+ done();
});
});
});
});
+
});
Please sign in to comment.
Something went wrong with that request. Please try again.