Skip to content

Commit 978cfcf

Browse files
committed
Update tests (tape ^5.8.1) + expected images
1 parent 4951b99 commit 978cfcf

20 files changed

+153
-151
lines changed

test/compositing.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ test('should stitch input images correctly', (assert) => {
3535

3636
var output_image = new mapnik.Image(512, 512);
3737
output_image.premultiply();
38+
assert.plan(20);
3839
input.forEach(function (item, index) {
3940
item[0].premultiply();
4041
output_image.composite(item[0], {dx: item[1], dy: item[2]}, function(err) {
@@ -59,7 +60,6 @@ test('should stitch input images correctly', (assert) => {
5960
});
6061
});
6162
});
62-
assert.end();
6363
});
6464

6565
test('should fail with bad parameters', (assert) => {
Loading
Loading
Loading
Loading
Loading
Loading
Loading

test/data/vector_tile/nz-1.png

45 Bytes
Loading

test/data/vector_tile/nz-1b.png

55 Bytes
Loading
Binary file not shown.
Binary file not shown.
923 Bytes
Binary file not shown.
923 Bytes
Binary file not shown.

test/geotiff-load.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var path = require('path');
88
// puts unnatural, odd, and intentionally racey load on opening geotiff
99

1010
test('should be able to open geotiff various ways without crashing', (assert) => {
11+
assert.plan(5)
1112
mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'gdal.input'));
1213
var vtile = new mapnik.VectorTile(0, 0, 0);
1314
var map = new mapnik.Map(256, 256);
@@ -23,6 +24,5 @@ test('should be able to open geotiff various ways without crashing', (assert) =>
2324
map3.render(vtile,{},function(err,vtile) {
2425
if (err) throw err;
2526
assert.ok(vtile);
26-
assert.end();
2727
});
2828
});

test/image.svg.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ test('should err with async non-existent file', (assert) => {
152152
});
153153
});
154154

155-
test('should not error with async in non-strict mode on svg with validation and parse errors', (assert) => {
155+
test('should error with async in non-strict mode on svg with validation and parse errors', (assert) => {
156156
mapnik.Image.fromSVG('./test/data/vector_tile/errors.svg', {strict:false}, function(err, svg) {
157-
assert.ok(!err);
158-
assert.ok(svg);
157+
assert.ok(err);
158+
assert.equals(svg, undefined);
159159
assert.end();
160160
});
161161
});
@@ -311,12 +311,12 @@ test('svg scaling', (assert) => {
311311

312312
test('svg viewBox', (assert) => {
313313
var svgdata = '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"/>';
314-
// "em" units are not supported, use viewBox to determine viewport
314+
// by default 1em is equivalent to 16px
315315
var buffer = Buffer.from(svgdata);
316316
var img = mapnik.Image.fromSVGBytesSync(buffer, {scale: 1.0});
317317
assert.ok(img);
318318
assert.ok(img instanceof mapnik.Image);
319-
assert.equal(img.width(), 24);
320-
assert.equal(img.height(), 24);
319+
assert.equal(img.width(), 16);
320+
assert.equal(img.height(), 16);
321321
assert.end();
322322
});

test/image.test.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ test('should initialize image successfully with options', (assert) => {
4343

4444

4545
test('should throw with invalid encoding', (assert) => {
46+
assert.plan(11);
4647
var im = new mapnik.Image(256, 256);
4748
assert.throws(function() { im.encodeSync('foo'); });
4849
assert.throws(function() { im.encodeSync(1); });
@@ -57,20 +58,18 @@ test('should throw with invalid encoding', (assert) => {
5758
im.encode('foo', {}, function(err, result) {
5859
assert.throws(function() { if (err) throw err; });
5960
});
60-
assert.end();
6161
});
6262

6363

6464
test('should encode with a pallete', (assert) => {
6565
var im = new mapnik.Image(256, 256);
6666
var pal = new mapnik.Palette(Buffer.from('\xff\x09\x93\xFF\x01\x02\x03\x04','ascii'));
67+
assert.plan(2);
6768
assert.ok(im.encodeSync('png', {palette:pal}));
68-
6969
im.encode('png', {palette:pal}, function(err, result) {
7070
if (err) throw err;
7171
assert.ok(result);
7272
});
73-
assert.end();
7473
});
7574

7675

test/proj_transform.test.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ test('should throw with invalid coords (4326 -> 3873)', (assert) => {
8181
var from = new mapnik.Projection('epsg:4326');
8282
var to = new mapnik.Projection('epsg:3873');
8383
var trans = new mapnik.ProjTransform(from,to);
84-
var long_lat_coords = [-190, 95];
8584
assert.throws(function() { trans.forward(); });
8685
assert.throws(function() { trans.forward(null); });
8786
assert.throws(function() { trans.forward([1,2,3]); });
88-
assert.throws(function() { trans.forward(long_lat_coords); });
87+
var output = trans.forward([-190, 95])
88+
assert.equal(output[0], Infinity)
89+
assert.equal(output[1], Infinity);
8990
assert.end();
9091
});
9192

@@ -97,7 +98,9 @@ test('should throw with invalid coords (3873 -> 4326) backward', (assert) => {
9798
assert.throws(function() { trans.backward(); });
9899
assert.throws(function() { trans.backward(null); });
99100
assert.throws(function() { trans.backward([1,2,3]); });
100-
assert.throws(function() { trans.backward(long_lat_coords); });
101+
var output = trans.backward(long_lat_coords);
102+
assert.equal(output[0], Infinity);
103+
assert.equal(output[1], Infinity);
101104
assert.end();
102105
});
103106

@@ -121,20 +124,20 @@ test('should backward bbox properly (3857 -> 4326)', (assert) => {
121124
assert.end();
122125
});
123126

124-
test('should throw with invalid bbox (4326 -> 3873)', (assert) => {
127+
test('should not throw with invalid bbox (4326 -> 3873)', (assert) => {
125128
var from = new mapnik.Projection('epsg:4326');
126129
var to = new mapnik.Projection('epsg:3873');
127130
var trans = new mapnik.ProjTransform(from,to);
128131
var long_lat_box = [-180,90,180,90];
129-
assert.throws(function() { trans.forward(long_lat_box); });
132+
assert.doesNotThrow(function() { trans.forward(long_lat_box); });
130133
assert.end();
131134
});
132135

133-
test('should throw with invalid bbox (3873 -> 4326) backward', (assert) => {
136+
test('should not throw with invalid bbox (3873 -> 4326) backward', (assert) => {
134137
var from = new mapnik.Projection('epsg:3873');
135138
var to = new mapnik.Projection('epsg:4326');
136139
var trans = new mapnik.ProjTransform(from,to);
137140
var long_lat_box = [-180,90,180,90];
138-
assert.throws(function() { trans.backward(long_lat_box); });
141+
assert.doesNotThrow(function() { trans.backward(long_lat_box); });
139142
assert.end();
140143
});

test/vector-tile.composite.test.js

-6
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ test('should render by overzooming+jpeg+near', (assert) => {
464464
vtile.render(map,new mapnik.Image(256,256),{buffer_size:256,image_format:"jpeg",image_scaling:"near"},function(err,im) {
465465
if (err) throw err;
466466
var expected_file = data_base +'/expected/2-1-1.png';
467-
//im.save(data_base +'/expected/2-1-1.png');
468467
assert.equal(0,compare_to_image(im,expected_file));
469468
assert.end();
470469
});
@@ -498,7 +497,6 @@ test('should render by overzooming+webp+biliear', (assert) => {
498497
vtile.render(map,new mapnik.Image(256,256),{buffer_size:256,image_format:"webp",image_scaling:"bilinear"},function(err,im) {
499498
if (err) throw err;
500499
var expected_file = data_base +'/expected/2-1-1b.png';
501-
//im.save(data_base +'/expected/2-1-1b.png');
502500
assert.equal(0,compare_to_image(im,expected_file));
503501
assert.end();
504502
});
@@ -538,7 +536,6 @@ test('should render by overzooming+webp+biliear with threading mode auto', (asse
538536
vtile.render(map,new mapnik.Image(256,256),{buffer_size:256,image_format:"webp",image_scaling:"bilinear"},function(err,im) {
539537
if (err) throw err;
540538
var expected_file = data_base +'/expected/2-1-1b.png';
541-
//im.save(data_base +'/expected/2-1-1b.png');
542539
assert.equal(0,compare_to_image(im,expected_file));
543540
assert.end();
544541
});
@@ -578,7 +575,6 @@ test('should render by overzooming+webp+biliear with threading mode async', (ass
578575
vtile.render(map,new mapnik.Image(256,256),{buffer_size:256,image_format:"webp",image_scaling:"bilinear"},function(err,im) {
579576
if (err) throw err;
580577
var expected_file = data_base +'/expected/2-1-1b.png';
581-
//im.save(data_base +'/expected/2-1-1b.png');
582578
assert.equal(0,compare_to_image(im,expected_file));
583579
assert.end();
584580
});
@@ -615,7 +611,6 @@ test('should render by overzooming (drops point)', (assert) => {
615611
vtile.render(map,new mapnik.Image(256,256),{buffer_size:256},function(err,im) {
616612
if (err) throw err;
617613
var expected_file = data_base +'/expected/2-1-1-no-point.png';
618-
//im.save(data_base +'/expected/2-1-1-no-point.png');
619614
assert.equal(0,compare_to_image(im,expected_file));
620615
assert.end();
621616
});
@@ -652,7 +647,6 @@ test('should render by underzooming or mosaicing', (assert) => {
652647
vtile.render(map,new mapnik.Image(256,256),{buffer_size:256},function(err,im) {
653648
if (err) throw err;
654649
var expected_file = data_base +'/expected/0-0-0-mosaic.png';
655-
//im.save(data_base + '/expected/0-0-0-mosaic.png');
656650
assert.equal(0,compare_to_image(im,expected_file));
657651
assert.end();
658652
});

0 commit comments

Comments
 (0)