Files
pubky-core/pubky-client/pkg/test/http.js
Severin Alexander Bühler 6f94333101 chore: Renamed pubky member dir to pubky-client (#90)
* chore: Renamed pubky member dir to pubky-client

* fixed paths

* fixed wasm test workflow
2025-03-21 14:24:34 +02:00

42 lines
842 B
JavaScript

import test from 'tape'
import { Client, Keypair, PublicKey } from '../index.cjs'
const TLD = '8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo';
test("basic fetch", async (t) => {
let client = Client.testnet();
// Normal TLD
{
let response = await client.fetch(`https://relay.pkarr.org/`);
t.equal(response.status, 200);
}
// Pubky
let response = await client.fetch(`https://${TLD}/`);
t.equal(response.status, 200);
})
test("fetch failed", async (t) => {
let client = Client.testnet();
// Normal TLD
{
let response = await client.fetch(`https://nonexistent.domain/`).catch(e => e);
t.ok(response instanceof Error);
}
// Pubky
let response = await client.fetch(`https://1pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ew1/`).catch(e => e);
t.ok(response instanceof Error);
})