Skip to content

Commit d1088df

Browse files
committed
N-API test/plugin.test.js (WIP) [skip ci]
1 parent 38ccfdf commit d1088df

File tree

1 file changed

+72
-72
lines changed

1 file changed

+72
-72
lines changed

test/plugin.test.js

+72-72
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
11
"use strict";
22

3+
var test = require('tape');
34
var mapnik = require('../');
4-
var assert = require('assert');
55
var path = require('path');
66

7-
describe('plugin testing', function() {
87

9-
it('test registering of datasource', function() {
10-
// Should register fine the first time
11-
// ensure shape input is registered
12-
mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
13-
// should not register again
14-
var b = mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
15-
assert.equal(false, b);
16-
17-
var ds_list = mapnik.datasources();
18-
var contains = false;
19-
for (var i = 0; i < ds_list.length; i++) {
20-
if (ds_list[i] === 'shape') contains = true;
21-
}
22-
assert.equal(contains, true);
23-
});
24-
25-
it('test registering of datasource - other naming', function() {
26-
// Should register fine the first time
27-
// ensure shape input is registered
28-
mapnik.registerDatasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
29-
// should not register again
30-
var b = mapnik.registerDatasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
31-
assert.equal(false, b);
32-
33-
var ds_list = mapnik.datasources();
34-
var contains = false;
35-
for (var i = 0; i < ds_list.length; i++) {
36-
if (ds_list[i] === 'shape') contains = true;
37-
}
38-
assert.equal(contains, true);
39-
});
8+
test('test registering of datasource', (assert) => {
9+
// Should register fine the first time
10+
// ensure shape input is registered
11+
mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
12+
// should not register again
13+
var b = mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
14+
assert.equal(false, b);
4015

16+
var ds_list = mapnik.datasources();
17+
var contains = false;
18+
for (var i = 0; i < ds_list.length; i++) {
19+
if (ds_list[i] === 'shape') contains = true;
20+
}
21+
assert.equal(contains, true);
22+
assert.end();
23+
});
24+
25+
test('test registering of datasource - other naming', (assert) => {
26+
// Should register fine the first time
27+
// ensure shape input is registered
28+
mapnik.registerDatasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
29+
// should not register again
30+
var b = mapnik.registerDatasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
31+
assert.equal(false, b);
32+
33+
var ds_list = mapnik.datasources();
34+
var contains = false;
35+
for (var i = 0; i < ds_list.length; i++) {
36+
if (ds_list[i] === 'shape') contains = true;
37+
}
38+
assert.equal(contains, true);
39+
assert.end();
40+
});
4141

42-
it('should fail to register plugin', function() {
43-
44-
assert.throws(function() {
45-
mapnik.register_datasource();
46-
});
47-
assert.throws(function() {
48-
mapnik.register_datasource(1);
49-
});
50-
assert.throws(function() {
51-
mapnik.register_datasource('ab', 'c');
52-
});
53-
54-
assert.throws(function() {
55-
mapnik.register_datasources();
56-
});
57-
assert.throws(function() {
58-
mapnik.register_datasources(1);
59-
});
60-
assert.throws(function() {
61-
mapnik.register_datasources('ab', 'c');
62-
});
63-
});
64-
65-
it('test registering of multiple datasources', function() {
66-
// Should register fine the first time
67-
// ensure shape input is registered
68-
mapnik.register_datasources(mapnik.settings.paths.input_plugins);
69-
// should not register again
70-
var b = mapnik.register_datasources(mapnik.settings.paths.input_plugins);
71-
assert.equal(false, b);
72-
});
7342

74-
it('test registering of multiple datasources - alternate naming', function() {
75-
// Should register fine the first time
76-
// ensure shape input is registered
77-
mapnik.registerDatasources(mapnik.settings.paths.input_plugins);
78-
// should not register again
79-
var b = mapnik.registerDatasources(mapnik.settings.paths.input_plugins);
80-
assert.equal(false, b);
81-
});
43+
test('should fail to register plugin', (assert) => {
8244

45+
assert.throws(function() {
46+
mapnik.register_datasource();
47+
});
48+
assert.throws(function() {
49+
mapnik.register_datasource(1);
50+
});
51+
assert.throws(function() {
52+
mapnik.register_datasource('ab', 'c');
53+
});
54+
55+
assert.throws(function() {
56+
mapnik.register_datasources();
57+
});
58+
assert.throws(function() {
59+
mapnik.register_datasources(1);
60+
});
61+
assert.throws(function() {
62+
mapnik.register_datasources('ab', 'c');
63+
});
64+
assert.end();
8365
});
8466

67+
test('test registering of multiple datasources', (assert) => {
68+
// Should register fine the first time
69+
// ensure shape input is registered
70+
mapnik.register_datasources(mapnik.settings.paths.input_plugins);
71+
// should not register again
72+
var b = mapnik.register_datasources(mapnik.settings.paths.input_plugins);
73+
assert.equal(false, b);
74+
assert.end();
75+
});
8576

77+
test('test registering of multiple datasources - alternate naming', (assert) => {
78+
// Should register fine the first time
79+
// ensure shape input is registered
80+
mapnik.registerDatasources(mapnik.settings.paths.input_plugins);
81+
// should not register again
82+
var b = mapnik.registerDatasources(mapnik.settings.paths.input_plugins);
83+
assert.equal(false, b);
84+
assert.end();
85+
});

0 commit comments

Comments
 (0)