Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ All notable changes to this project are documented in the [releases](https://git

**Compatibile with:**
[![Leaflet 1.x compatible!](https://img.shields.io/badge/Leaflet-1.7.0-1EB300.svg?style=flat)](http://leafletjs.com/reference.html)
[![d3.js v6 compatibile!](https://img.shields.io/badge/d3.js-6.5-1EB300.svg?style=flat)](https://www.npmjs.com/package/d3)
[![@tmcw/togeojson v4.6.0 compatibile!](https://img.shields.io/badge/@tmcw/togeojson-4.6-1EB300.svg?style=flat)](https://www.npmjs.com/package/@tmcw/togeojson)
[![d3.js v7 compatibile!](https://img.shields.io/badge/d3.js-7.8-1EB300.svg?style=flat)](https://www.npmjs.com/package/d3)
[![@tmcw/togeojson v5 compatibile!](https://img.shields.io/badge/@tmcw/togeojson-5.6-1EB300.svg?style=flat)](https://www.npmjs.com/package/@tmcw/togeojson)


---
Expand Down
12 changes: 12 additions & 0 deletions examples/leaflet-elevation_almost-over.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ test('almostOver', async ({ page }) => {
assert.equal(step_2.over_layers, 1);
assert.equal(step_3.over_layers, 9);

/**
* List of points where altitude == 0
*
* <ele>0</ele> values shouldn't be interpreted as an empty ("false" or "undefined") value.
*
* @see https://github.com/Raruto/leaflet-elevation/issues/259
*/
[1029, 1030, 2048, 3747, 3843, 3845, 3891, 3965, 3966, 4057, 4058, 4072, 4262, 4263, 4264, 4269, 11284].forEach(idx => {
assert.is(step_2.data[idx].z, 0);
});

}, 15000);

test.run();
Expand All @@ -90,6 +101,7 @@ async function load_trace(page, trace_url) {
option: ctrl.options.almostOver,
over_layers: map.almostOver._layers.length,
map_layers: Object.keys(map._layers).length,
data: ctrl._data,
}));
});
ctrl.load(trace_url);
Expand Down
4 changes: 2 additions & 2 deletions examples/leaflet-elevation_hoverable-tracks.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
searchControl: false,
loadingControl: false,
plugins: [
"d3@6.5.0/dist/d3.min.js",
"@tmcw/togeojson@4.5.0/dist/togeojson.umd.js",
"d3@7.8.4/dist/d3.min.js",
"@tmcw/togeojson@5.6.2/dist/togeojson.umd.js",
"leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js",
"leaflet-almostover@1.0.1/src/leaflet.almostover.js",
"@raruto/leaflet-elevation@2.4.0/libs/leaflet-distance-marker.css",
Expand Down
4 changes: 2 additions & 2 deletions examples/leaflet-elevation_toggable-charts.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
searchControl: false,
loadingControl: false,
plugins: [
"d3@6.5.0/dist/d3.min.js",
"@tmcw/togeojson@4.5.0/dist/togeojson.umd.js",
"d3@7.8.4/dist/d3.min.js",
"@tmcw/togeojson@5.6.2/dist/togeojson.umd.js",
"leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js",
"leaflet-almostover@1.0.1/src/leaflet.almostover.js",
"@raruto/leaflet-elevation@2.4.0/libs/leaflet-distance-marker.css",
Expand Down
2 changes: 1 addition & 1 deletion examples/leaflet-elevation_upload-gpx.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.4.0/dist/leaflet-elevation.min.js"></script>

<!-- leaflet-filelayer -->
<script src="https://unpkg.com/@tmcw/togeojson@4.5.0/dist/togeojson.umd.js"></script>
<script src="https://unpkg.com/@tmcw/togeojson@5.6.2/dist/togeojson.umd.js"></script>
<script src="https://unpkg.com/leaflet-filelayer@1.2.0/src/leaflet.filelayer.js"></script>

<style>
Expand Down
35 changes: 7 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"uvu": "^0.5.6"
},
"peerDependencies": {
"@tmcw/togeojson": "5.6.0",
"@tmcw/togeojson": "5.6.2",
"d3": "7.8.4",
"leaflet": "^1.7.0",
"leaflet-i18n": "^0.3.1"
Expand Down
2 changes: 1 addition & 1 deletion src/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
__mileFactor: 0.621371, // 1 km = (0.621371 mi)
__footFactor: 3.28084, // 1 m = (3.28084 ft)
__D3: 'https://unpkg.com/d3@7.8.4/dist/d3.min.js',
__TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@5.6.0/dist/togeojson.umd.js',
__TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@5.6.2/dist/togeojson.umd.js',
__LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.10.1/src/leaflet.geometryutil.js',
__LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
__LHOTLINE: '../libs/leaflet-hotline.min.js',
Expand Down
39 changes: 28 additions & 11 deletions test/setup/http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,31 @@ import { suite as uvu_suite } from 'uvu';
import { exec } from 'child_process';
import { chromium } from 'playwright';

process.on('exit', async () => {
await globalThis.server.kill('SIGTERM');
})

/**
* Start HTTP server
*/
export async function setup(ctx) {
ctx.server = new AbortController();
exec('http-server', { signal: ctx.server.signal });
if (!globalThis.server) {
await new Promise((resolve) => {
globalThis.server = exec('http-server');
globalThis.server.stdout.on('data', (msg) => {
// console.log(msg);
// if (msg.toString().match(/Starting up/)) {
if (msg.toString().indexOf('Hit CTRL-C to stop the server')) {
resolve();
// setTimeout(resolve, 1500);
}
});
});
}
ctx.localhost = 'http://localhost:8080';
ctx.browser = await chromium.launch();
ctx.context = await ctx.browser.newContext();
ctx.context.route(/.html$/, mock_cdn_urls);
ctx.context.route(/.html$/, await mock_cdn_urls);
ctx.page = await ctx.context.newPage();
}

Expand All @@ -21,7 +36,6 @@ export async function setup(ctx) {
export async function reset(ctx) {
await ctx.context.close();
await ctx.browser.close();
try { ctx.server.abort(); } catch(e) { }
}

/**
Expand All @@ -47,8 +61,11 @@ export function suite() {
test.before(setup);
test.after(reset);
test.before.each(async ({ localhost, page }) => {
page.on('console', msg => console.log(msg.text()))
page.on('console', msg => console.log(msg.text()));
page.on('requestfailed', request => { console.log(request.failure().errorText, request.url()); });
page.on('pageerror', exception => { console.log(exception); });
await page.goto((new URL(arguments[0], localhost)).toString());
await page.waitForLoadState('domcontentloaded');
});
// augment uvu `test` function with a third parameter `timeout`
return new Proxy(test, {
Expand All @@ -63,13 +80,13 @@ export function suite() {
*
* @see https://github.com/lukeed/uvu/issues/33#issuecomment-879870292
*/
function timeout(handler, ms=10000) {
function timeout(handler, ms = 10000) {
return (ctx) => {
let timer
return Promise.race([
handler(ctx),
new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('[TIMEOUT] Maximum execution time exceeded: ' + ms + 'ms')), ms) })
]).finally(() => { clearTimeout(timer) })
let timer
return Promise.race([
handler(ctx),
new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('[TIMEOUT] Maximum execution time exceeded: ' + ms + 'ms')), ms) })
]).finally(() => { clearTimeout(timer) })
}
}

Expand Down