forked from CartoDB/node-mapnik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.test.js
85 lines (70 loc) · 2.87 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
"use strict";
var mapnik = require('../');
var assert = require('assert');
var path = require('path');
describe('plugin testing', function() {
it('test registering of datasource', function() {
// 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);
});
it('test registering of datasource - other naming', function() {
// 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);
});
it('should fail to register plugin', function() {
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');
});
});
it('test registering of multiple datasources', function() {
// 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);
});
it('test registering of multiple datasources - alternate naming', function() {
// 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);
});
});