mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 19:01:08 +00:00
port tests to node 18 test module; remove zora dep
This commit is contained in:
@@ -1,58 +1,72 @@
|
||||
import { test } from "zora";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert";
|
||||
|
||||
import { pmtiles_path, tile_path } from "./index";
|
||||
|
||||
test("pmtiles path", (assertion) => {
|
||||
test("pmtiles path", () => {
|
||||
let result = pmtiles_path("foo", undefined);
|
||||
assertion.equal(result, "foo.pmtiles");
|
||||
assert.strictEqual(result, "foo.pmtiles");
|
||||
});
|
||||
|
||||
test("pmtiles path", (assertion) => {
|
||||
let result = pmtiles_path("foo","folder/{name}/file.pmtiles");
|
||||
assertion.equal(result, "folder/foo/file.pmtiles");
|
||||
test("pmtiles path", () => {
|
||||
let result = pmtiles_path("foo", "folder/{name}/file.pmtiles");
|
||||
assert.strictEqual(result, "folder/foo/file.pmtiles");
|
||||
});
|
||||
|
||||
test("pmtiles path with slash", (assertion) => {
|
||||
let result = pmtiles_path("foo/bar","folder/{name}/file.pmtiles");
|
||||
assertion.equal(result, "folder/foo/bar/file.pmtiles");
|
||||
test("pmtiles path with slash", () => {
|
||||
let result = pmtiles_path("foo/bar", "folder/{name}/file.pmtiles");
|
||||
assert.strictEqual(result, "folder/foo/bar/file.pmtiles");
|
||||
});
|
||||
|
||||
test("pmtiles path with multiple names", (assertion) => {
|
||||
let result = pmtiles_path("slug","folder/{name}/{name}.pmtiles");
|
||||
assertion.equal(result, "folder/slug/slug.pmtiles");
|
||||
result = pmtiles_path("foo/bar","folder/{name}/{name}.pmtiles");
|
||||
assertion.equal(result, "folder/foo/bar/foo/bar.pmtiles");
|
||||
test("pmtiles path with multiple names", () => {
|
||||
let result = pmtiles_path("slug", "folder/{name}/{name}.pmtiles");
|
||||
assert.strictEqual(result, "folder/slug/slug.pmtiles");
|
||||
result = pmtiles_path("foo/bar", "folder/{name}/{name}.pmtiles");
|
||||
assert.strictEqual(result, "folder/foo/bar/foo/bar.pmtiles");
|
||||
});
|
||||
|
||||
test("parse tile default", (assertion) => {
|
||||
let {ok, name, tile, ext} = tile_path("abcd");
|
||||
assertion.equal(ok, false);
|
||||
test("parse tile default", () => {
|
||||
let { ok, name, tile, ext } = tile_path("abcd");
|
||||
assert.strictEqual(ok, false);
|
||||
|
||||
({name, tile} = tile_path("/foo/11/22/33.pbf"));
|
||||
assertion.equal(name,"foo");
|
||||
assertion.equal(tile[0],11);
|
||||
assertion.equal(tile[1],22);
|
||||
assertion.equal(tile[2],33);
|
||||
({ name, tile } = tile_path("/foo/11/22/33.pbf"));
|
||||
assert.strictEqual(name, "foo");
|
||||
assert.strictEqual(tile[0], 11);
|
||||
assert.strictEqual(tile[1], 22);
|
||||
assert.strictEqual(tile[2], 33);
|
||||
});
|
||||
|
||||
test("parse tile path setting", (assertion) => {
|
||||
let {ok, name, tile, ext} = tile_path("/foo/11/22/33.pbf","/{name}/{z}/{y}/{x}.{ext}");
|
||||
assertion.equal(tile[1],33);
|
||||
assertion.equal(tile[2],22);
|
||||
assertion.equal(ext,"pbf");
|
||||
({ok, name, tile, ext} = tile_path("/tiles/foo/4/2/3.mvt","/tiles/{name}/{z}/{x}/{y}.{ext}"));
|
||||
assertion.equal(name,"foo");
|
||||
assertion.equal(tile[0],4);
|
||||
assertion.equal(tile[1],2);
|
||||
assertion.equal(tile[2],3);
|
||||
assertion.equal(ext,"mvt");
|
||||
test("parse tile path setting", () => {
|
||||
let { ok, name, tile, ext } = tile_path(
|
||||
"/foo/11/22/33.pbf",
|
||||
"/{name}/{z}/{y}/{x}.{ext}"
|
||||
);
|
||||
assert.strictEqual(tile[1], 33);
|
||||
assert.strictEqual(tile[2], 22);
|
||||
assert.strictEqual(ext, "pbf");
|
||||
({ ok, name, tile, ext } = tile_path(
|
||||
"/tiles/foo/4/2/3.mvt",
|
||||
"/tiles/{name}/{z}/{x}/{y}.{ext}"
|
||||
));
|
||||
assert.strictEqual(name, "foo");
|
||||
assert.strictEqual(tile[0], 4);
|
||||
assert.strictEqual(tile[1], 2);
|
||||
assert.strictEqual(tile[2], 3);
|
||||
assert.strictEqual(ext, "mvt");
|
||||
});
|
||||
|
||||
test("parse tile path setting special chars", (assertion) => {
|
||||
let {ok, name, tile, ext} = tile_path("/folder(new/foo/11/22/33.pbf","/folder(new/{name}/{z}/{y}/{x}.{ext}");
|
||||
assertion.equal(name,"foo");
|
||||
test("parse tile path setting special chars", () => {
|
||||
let { ok, name, tile, ext } = tile_path(
|
||||
"/folder(new/foo/11/22/33.pbf",
|
||||
"/folder(new/{name}/{z}/{y}/{x}.{ext}"
|
||||
);
|
||||
assert.strictEqual(name, "foo");
|
||||
});
|
||||
|
||||
test("parse tile path setting slash", (assertion) => {
|
||||
let {ok, name, tile, ext} = tile_path("/foo/bar/11/22/33.pbf","/{name}/{z}/{y}/{x}.{ext}");
|
||||
assertion.equal(name,"foo/bar");
|
||||
test("parse tile path setting slash", () => {
|
||||
let { ok, name, tile, ext } = tile_path(
|
||||
"/foo/bar/11/22/33.pbf",
|
||||
"/{name}/{z}/{y}/{x}.{ext}"
|
||||
);
|
||||
assert.strictEqual(name, "foo/bar");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user