This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
/
external.test.js
87 lines (73 loc) · 3.81 KB
/
external.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
86
87
var External = require('../lib/carto').External;
var path = require('path'),
assert = require('assert'),
fs = require('fs'),
helper = require('./support/helper');
var env = {
data_dir: path.join(__dirname, 'data'),
local_data_dir: path.join(__dirname, 'local')
};
// Delete the data directory first to start with a clean slate.
helper.rmrf(env.data_dir);
exports['test External with local file'] = function(beforeExit) {
var context = { tests: 0 };
beforeExit(function() { assert.equal(context.tests, 1); });
new External(env, 'style.mss')
.on('complete', function(external) {
assert.ok(external instanceof External);
helper.md5File(external.path(), '7e659de8be9aacf42c356774a60adf00', context);
});
};
exports['test External with remote file'] = function(beforeExit) {
var context = { tests: 0 };
beforeExit(function() { assert.equal(context.tests, 1); });
new External(env, 'http://tilemill-data.s3.amazonaws.com/test_data/ipsum.json')
.on('complete', function(external) {
assert.ok(external instanceof External);
helper.md5File(external.path(), '651ea0ff31786e9be9012112b21573be', context);
});
};
exports['test External with local zipfile'] = function(beforeExit) {
var context = { tests: 0 };
beforeExit(function() { assert.equal(context.tests, 5); });
new External(env, 'shapes.zip').on('complete',
function(external) {
assert.ok(external instanceof External);
helper.isDirectory(external.path(), context);
helper.md5File(path.join(external.path(), 'world_borders.dbf'), '5dd220a6470ac525a5dbd8fce728c8c6', context);
helper.md5File(path.join(external.path(), 'world_borders.prj'), '15541cb58c5710db8f6ded679d93f20e', context);
helper.md5File(path.join(external.path(), 'world_borders.shp'), '0ce4134dd36385cc359890af9d527c02', context);
helper.md5File(path.join(external.path(), 'world_borders.shx'), '3cac59ecc9ddf2a1053de46a7f9e9168', context);
});
};
exports['test External with remote zipfile'] = function(beforeExit) {
var context = { tests: 0 };
beforeExit(function() { assert.equal(context.tests, 5); });
new External(env, 'http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip')
.on('complete', function(external) {
assert.ok(external instanceof External);
helper.isDirectory(external.path(), context);
helper.md5File(path.join(external.path(), 'world_borders.dbf'), '575521efe28ff68ecd5e7606e326fd2b', context);
helper.md5File(path.join(external.path(), 'world_borders.prj'), 'be918e3fd426824bae21eba8a79b1257', context);
helper.md5File(path.join(external.path(), 'world_borders.shp'), '30d9b1709ba596f092abea49f4f9401b', context);
helper.md5File(path.join(external.path(), 'world_borders.shx'), '535cb8568177f7ab95ab823cd6c16eb8', context);
});
};
exports['test External with remote KML file'] = function(beforeExit) {
var context = { tests: 0 };
beforeExit(function() { assert.equal(context.tests, 1); });
new External(env, 'http://tilemill-data.s3.amazonaws.com/couchsurf.kml')
.on('complete', function(external) {
assert.ok(external instanceof External);
helper.md5File(external.path(), 'f8aea6d693a48dabdc7ea3586cce57f7', context);
});
};
exports['test External with DS_Store'] = function(beforeExit) {
new External(env, 'http://tilemill-testing.s3.amazonaws.com/carto/station_circles_bad.zip')
.on('complete', function(external) {
assert.ok(external instanceof External);
external.findDataFile(function(err, file) {
assert.eql('station_circles.shp', path.basename(file), 'The non-dot file was chosen');
});
});
};