-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.spec.ts
47 lines (40 loc) · 1.79 KB
/
examples.spec.ts
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
import yaml from "yaml";
import fs from "fs";
import { fetchStaticFeatureCollection } from "./examples";
describe("canonical data sources", function () {
let sources: any;
beforeAll(function () {
const contents = fs.readFileSync("locations.yml", "utf-8");
const { geojson } = yaml.parse(contents);
sources = geojson
})
describe("multipolygon", function () {
test("data reduction", async function () {
const [reduced, stats] = await fetchStaticFeatureCollection("https://oceanicsdotio.nyc3.cdn.digitaloceanspaces.com/assets/maine-towns.json");
expect(reduced.length).toBeGreaterThan(0);
function testFeature({ features, ...rest }: any) {
expect(rest.type).toBe("FeatureCollection");
expect(features.length).toBe(1);
}
reduced.forEach(testFeature);
const delta = stats.before - stats.after;
expect(delta).toBeGreaterThan(0);
})
})
describe("aquaculture", function () {
test("aquaculture leases", async function () {
const [leases] = sources.filter((each: any) => each.id === "aquaculture-leases-direct")
const response = await fetch(leases.url);
const parsed = await response.json()
expect(parsed.type === "FeatureCollection")
expect(parsed.features.length > 0)
})
test("limited purpose aquaculture licenses", async function () {
const [licenses] = sources.filter((each: any) => each.id === "limited-purpose-licenses")
const response = await fetch(licenses.url);
const parsed = await response.json()
expect(parsed.type === "FeatureCollection")
expect(parsed.features.length > 0)
})
})
})