-
Notifications
You must be signed in to change notification settings - Fork 166
/
plugin.test.js
85 lines (73 loc) · 2.5 KB
/
plugin.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"use strict";
var test = require('tape');
var mapnik = require('../');
var path = require('path');
test('test registering of datasource', (assert) => {
// Should register fine the first time
// ensure shape input is registered
mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
// should not register again
var b = mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
assert.equal(false, b);
var ds_list = mapnik.datasources();
var contains = false;
for (var i = 0; i < ds_list.length; i++) {
if (ds_list[i] === 'shape') contains = true;
}
assert.equal(contains, true);
assert.end();
});
test('test registering of datasource - other naming', (assert) => {
// Should register fine the first time
// ensure shape input is registered
mapnik.registerDatasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
// should not register again
var b = mapnik.registerDatasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
assert.equal(false, b);
var ds_list = mapnik.datasources();
var contains = false;
for (var i = 0; i < ds_list.length; i++) {
if (ds_list[i] === 'shape') contains = true;
}
assert.equal(contains, true);
assert.end();
});
test('should fail to register plugin', (assert) => {
assert.throws(function() {
mapnik.register_datasource();
});
assert.throws(function() {
mapnik.register_datasource(1);
});
assert.throws(function() {
mapnik.register_datasource('ab', 'c');
});
assert.throws(function() {
mapnik.register_datasources();
});
assert.throws(function() {
mapnik.register_datasources(1);
});
assert.throws(function() {
mapnik.register_datasources('ab', 'c');
});
assert.end();
});
test('test registering of multiple datasources', (assert) => {
// Should register fine the first time
// ensure shape input is registered
mapnik.register_datasources(mapnik.settings.paths.input_plugins);
// should not register again
var b = mapnik.register_datasources(mapnik.settings.paths.input_plugins);
assert.equal(false, b);
assert.end();
});
test('test registering of multiple datasources - alternate naming', (assert) => {
// Should register fine the first time
// ensure shape input is registered
mapnik.registerDatasources(mapnik.settings.paths.input_plugins);
// should not register again
var b = mapnik.registerDatasources(mapnik.settings.paths.input_plugins);
assert.equal(false, b);
assert.end();
});