mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
port tests to node 18 test module; remove zora dep
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { test } from "zora";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert";
|
||||
|
||||
import {
|
||||
unshift,
|
||||
@@ -12,7 +13,7 @@ import {
|
||||
createDirectory,
|
||||
} from "../v2";
|
||||
|
||||
test("stub data", (assertion) => {
|
||||
test("stub data", () => {
|
||||
let dataview = new DataView(createDirectory([
|
||||
{ z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, is_dir: false },
|
||||
{
|
||||
@@ -29,12 +30,12 @@ test("stub data", (assertion) => {
|
||||
var y = getUint24(dataview, 17 + 4);
|
||||
var offset = getUint48(dataview, 17 + 7);
|
||||
var length = dataview.getUint32(17 + 13, true);
|
||||
assertion.ok(z_raw === 14);
|
||||
assertion.ok(x === 16383);
|
||||
assertion.ok(y === 16383);
|
||||
assert.strictEqual(z_raw,14);
|
||||
assert.strictEqual(x,16383);
|
||||
assert.strictEqual(y,16383);
|
||||
});
|
||||
|
||||
test("get entry", (assertion) => {
|
||||
test("get entry", () => {
|
||||
let view = new DataView(createDirectory([
|
||||
{ z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, is_dir: false },
|
||||
{
|
||||
@@ -47,16 +48,16 @@ test("get entry", (assertion) => {
|
||||
},
|
||||
]));
|
||||
let entry = queryTile(view, 14, 16383, 16383);
|
||||
assertion.ok(entry!.z === 14);
|
||||
assertion.ok(entry!.x === 16383);
|
||||
assertion.ok(entry!.y === 16383);
|
||||
assertion.ok(entry!.offset === 999999);
|
||||
assertion.ok(entry!.length === 999);
|
||||
assertion.ok(entry!.is_dir === false);
|
||||
assertion.ok(queryLeafdir(view, 14, 16383, 16383) === null);
|
||||
assert.strictEqual(entry!.z,14);
|
||||
assert.strictEqual(entry!.x,16383);
|
||||
assert.strictEqual(entry!.y,16383);
|
||||
assert.strictEqual(entry!.offset,999999);
|
||||
assert.strictEqual(entry!.length,999);
|
||||
assert.strictEqual(entry!.is_dir,false);
|
||||
assert.strictEqual(queryLeafdir(view, 14, 16383, 16383),null);
|
||||
});
|
||||
|
||||
test("get leafdir", (assertion) => {
|
||||
test("get leafdir", () => {
|
||||
let view = new DataView(createDirectory([
|
||||
{
|
||||
z: 14,
|
||||
@@ -68,16 +69,16 @@ test("get leafdir", (assertion) => {
|
||||
},
|
||||
]));
|
||||
let entry = queryLeafdir(view, 14, 16383, 16383);
|
||||
assertion.ok(entry!.z === 14);
|
||||
assertion.ok(entry!.x === 16383);
|
||||
assertion.ok(entry!.y === 16383);
|
||||
assertion.ok(entry!.offset === 999999);
|
||||
assertion.ok(entry!.length === 999);
|
||||
assertion.ok(entry!.is_dir === true);
|
||||
assertion.ok(queryTile(view, 14, 16383, 16383) === null);
|
||||
assert.strictEqual(entry!.z,14);
|
||||
assert.strictEqual(entry!.x,16383);
|
||||
assert.strictEqual(entry!.y,16383);
|
||||
assert.strictEqual(entry!.offset,999999);
|
||||
assert.strictEqual(entry!.length,999);
|
||||
assert.strictEqual(entry!.is_dir,true);
|
||||
assert.strictEqual(queryTile(view, 14, 16383, 16383),null);
|
||||
});
|
||||
|
||||
test("derive the leaf level", (assertion) => {
|
||||
test("derive the leaf level", () => {
|
||||
let view = new DataView(createDirectory([
|
||||
{
|
||||
z: 6,
|
||||
@@ -89,9 +90,9 @@ test("derive the leaf level", (assertion) => {
|
||||
},
|
||||
]));
|
||||
let leaf = deriveLeaf(view,{z:7,x:6,y:6});
|
||||
assertion.ok(leaf!.z === 6);
|
||||
assertion.ok(leaf!.x === 3);
|
||||
assertion.ok(leaf!.y === 3);
|
||||
assert.strictEqual(leaf!.z,6);
|
||||
assert.strictEqual(leaf!.x,3);
|
||||
assert.strictEqual(leaf!.y,3);
|
||||
view = new DataView(createDirectory([
|
||||
{
|
||||
z: 6,
|
||||
@@ -103,10 +104,10 @@ test("derive the leaf level", (assertion) => {
|
||||
},
|
||||
]));
|
||||
leaf = deriveLeaf(view,{z:7,x:6,y:6});
|
||||
assertion.ok(leaf === null);
|
||||
assert.strictEqual(leaf,null);
|
||||
});
|
||||
|
||||
test("convert spec v1 directory to spec v2 directory", (assertion) => {
|
||||
test("convert spec v1 directory to spec v2 directory", () => {
|
||||
let view = new DataView(createDirectory([
|
||||
{
|
||||
z: 7,
|
||||
@@ -134,16 +135,16 @@ test("convert spec v1 directory to spec v2 directory", (assertion) => {
|
||||
},
|
||||
]));
|
||||
let entry = queryLeafdir(view, 7, 3, 3);
|
||||
assertion.ok(entry!.offset === 3);
|
||||
assert.strictEqual(entry!.offset,3);
|
||||
entry = queryTile(view, 6, 2, 2);
|
||||
assertion.ok(entry!.offset === 2);
|
||||
assert.strictEqual(entry!.offset,2);
|
||||
entry = queryTile(view, 6, 2, 1);
|
||||
assertion.ok(entry!.offset === 1);
|
||||
assert.strictEqual(entry!.offset,1);
|
||||
|
||||
entry = parseEntry(view, 0);
|
||||
assertion.ok(entry!.offset === 1);
|
||||
assert.strictEqual(entry!.offset,1);
|
||||
entry = parseEntry(view, 1);
|
||||
assertion.ok(entry!.offset === 2);
|
||||
assert.strictEqual(entry!.offset,2);
|
||||
entry = parseEntry(view, 2);
|
||||
assertion.ok(entry!.offset === 3);
|
||||
assert.strictEqual(entry!.offset,3);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user