forked from Turfjs/turf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
29 lines (26 loc) · 860 Bytes
/
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
const fs = require("fs");
const test = require("tape");
const path = require("path");
const load = require("load-json-file");
const write = require("write-json-file");
const length = require("./index").default;
const directories = {
in: path.join(__dirname, "test", "in") + path.sep,
out: path.join(__dirname, "test", "out") + path.sep,
};
const fixtures = fs.readdirSync(directories.in).map((filename) => {
return {
filename,
name: path.parse(filename).name,
geojson: load.sync(directories.in + filename),
};
});
test("turf-length", (t) => {
for (const { name, geojson } of fixtures) {
const results = Math.round(length(geojson, { units: "feet" }));
if (process.env.REGEN)
write.sync(directories.out + name + ".json", results);
t.equal(results, load.sync(directories.out + name + ".json"), name);
}
t.end();
});