mfedderly 3cea4b5f12
Enable ESLint rule: @typescript-eslint/no-unused-vars (#1976)
* @typescript-eslint/no-unused-vars

* Re-add side-effectful method I accidentally removed

Co-authored-by: Matt Fedderly <mfedderly@palantir.com>
2020-12-10 07:50:55 -05:00

55 lines
1.4 KiB
JavaScript

const glob = require("glob");
const path = require("path");
const test = require("tape");
const load = require("load-json-file");
const { lineString } = require("@turf/helpers");
const booleanParallel = require("./dist/js/index.js").default;
test("turf-boolean-parallel", (t) => {
// True Fixtures
glob
.sync(path.join(__dirname, "test", "true", "**", "*.geojson"))
.forEach((filepath) => {
const name = path.parse(filepath).name;
const geojson = load.sync(filepath);
const line1 = geojson.features[0];
const line2 = geojson.features[1];
const result = booleanParallel(line1, line2);
t.true(result, "[true] " + name);
});
// False Fixtures
glob
.sync(path.join(__dirname, "test", "false", "**", "*.geojson"))
.forEach((filepath) => {
const name = path.parse(filepath).name;
const geojson = load.sync(filepath);
const line1 = geojson.features[0];
const line2 = geojson.features[1];
const result = booleanParallel(line1, line2);
t.false(result, "[false] " + name);
});
t.end();
});
test("turf-boolean-parallel -- throws", (t) => {
const line = lineString([
[0, 0],
[0, 1],
]);
t.throws(
() => booleanParallel({}, line),
/Invalid GeoJSON object for line1/,
"invalid types"
);
t.throws(
() => booleanParallel(line, {}),
/Invalid GeoJSON object for line2/,
"invalid types"
);
t.end();
});