34 lines
746 B
TypeScript
34 lines
746 B
TypeScript
import test from "ava";
|
|
import http from "http";
|
|
import { asDict, listingAsOrdered } from ".";
|
|
import { ListingResult, OrderedListing } 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("my passing test", async (t) => {
|
|
const data = (await fetchJSON(
|
|
"http://localhost:8093/api/hier/NATIVE"
|
|
)) as ListingResult;
|
|
|
|
console.log(asDict(Object.values(data)));
|
|
|
|
t.pass();
|
|
});
|