41 lines
No EOL
888 B
TypeScript
41 lines
No EOL
888 B
TypeScript
/*
|
|
import test from "ava";
|
|
import http from "http";
|
|
import { UpObject, UpEntry, UpListing } from ".";
|
|
import type { Address, IEntry, ListingResult } from "./types";
|
|
|
|
function fetchJSON(url: string): Promise<unknown> {
|
|
return new Promise((resolve, reject) => {
|
|
http
|
|
.get(url, (res) => {
|
|
let data = "";
|
|
|
|
res.on("data", (chunk) => {
|
|
data += chunk;
|
|
});
|
|
|
|
res.on("end", () => {
|
|
resolve(JSON.parse(data));
|
|
});
|
|
})
|
|
.on("error", (error) => {
|
|
reject(error);
|
|
});
|
|
});
|
|
}
|
|
|
|
test("basic hier listing", async (t) => {
|
|
const data = (await fetchJSON("http://localhost:8093/api/hier/NATIVE")) as {
|
|
target: Address;
|
|
entries: IEntry[];
|
|
};
|
|
|
|
const native = new UpObject(data.target);
|
|
|
|
// console.log(native.asDict(data.entries));
|
|
|
|
// console.log(asDict(Object.values(data)));
|
|
|
|
t.pass();
|
|
});
|
|
*/ |