|
1 |
| -import test from 'flug'; |
2 |
| -import fetch from 'cross-fetch'; |
3 |
| -import load from '../load'; |
4 |
| -import identify from './identify.module'; |
| 1 | +/** |
| 2 | + * @prettier |
| 3 | + */ |
| 4 | +import test from "flug"; |
| 5 | +import { serve } from "srvd"; |
| 6 | +import load from "../load"; |
| 7 | +import identify from "./identify.module"; |
5 | 8 |
|
6 |
| -const url = 'http://localhost:3000/data/test.tiff'; |
| 9 | +const url = "http://localhost:3000/data/test.tiff"; |
7 | 10 | const point = [80.63, 7.42];
|
8 | 11 | const expectedValue = 350.7;
|
9 | 12 |
|
10 |
| -test('Identified Point Correctly from file', async ({ eq }) => { |
11 |
| - const georaster = await fetch(url).then(r => r.arrayBuffer()).then(load); |
| 13 | +if (require.main === module) serve({ debug: true, port: 3000, wait: 3 }); |
| 14 | + |
| 15 | +test("(Legacy) Identified Point Correctly from file", async ({ eq }) => { |
| 16 | + const georaster = await load(url); |
12 | 17 | const values = identify(georaster, point)[0];
|
13 | 18 | eq(values, expectedValue);
|
14 | 19 | });
|
15 | 20 |
|
16 |
| -test('Try to identify point outside raster and correctly returned null from file', async ({ eq }) => { |
17 |
| - const georaster = await fetch(url).then(r => r.arrayBuffer()).then(load); |
18 |
| - const value = identify(georaster, [-200, 7.42]); |
19 |
| - eq(value, null); |
| 21 | +test("(Legacy) Try to identify point outside raster and correctly returned null from file", async ({ eq }) => { |
| 22 | + const georaster = await load(url); |
| 23 | + const values = identify(georaster, [-200, 7.42]); |
| 24 | + eq(values, null); |
20 | 25 | });
|
21 | 26 |
|
22 |
| -test('Identified Point Correctly from URL', async ({ eq }) => { |
| 27 | +test("(Legacy) Identified Point Correctly from URL", async ({ eq }) => { |
23 | 28 | const georaster = await load(url);
|
24 |
| - const values = await identify(georaster, point); |
| 29 | + const values = identify(georaster, point); |
25 | 30 | eq(values[0], expectedValue);
|
26 | 31 | });
|
27 | 32 |
|
28 |
| -test('Try to identify point outside raster and correctly returned null from URL', async ({ eq }) => { |
| 33 | +test("(Legacy) Try to identify point outside raster and correctly returned null from URL", async ({ eq }) => { |
29 | 34 | const georaster = await load(url);
|
30 |
| - const value = await identify(georaster, [-200, 7.42]); |
31 |
| - eq(value, null); |
| 35 | + const values = identify(georaster, [-200, 7.42]); |
| 36 | + eq(values, null); |
| 37 | +}); |
| 38 | + |
| 39 | +// modern |
| 40 | +test("(Modern) Identified Point Correctly from file", async ({ eq }) => { |
| 41 | + const values = await identify(url, point); |
| 42 | + eq(values, [expectedValue]); |
| 43 | +}); |
| 44 | + |
| 45 | +test("(Modern) Try to identify point outside raster and correctly returned null from file", async ({ eq }) => { |
| 46 | + const values = await identify(url, [-200, 7.42]); |
| 47 | + eq(values, null); |
| 48 | +}); |
| 49 | + |
| 50 | +test("(Modern) Identified Point Correctly from URL", async ({ eq }) => { |
| 51 | + const values = await identify(url, point); |
| 52 | + eq(values, [expectedValue]); |
| 53 | +}); |
| 54 | + |
| 55 | +test("(Modern) Try to identify point outside raster and correctly returned null from URL", async ({ eq }) => { |
| 56 | + const values = await identify(url, [-200, 7.42]); |
| 57 | + eq(values, null); |
32 | 58 | });
|
0 commit comments