Files
pubky-core/pubky-client/pkg/test/constructor.js
Severin Alexander Bühler a485d8c2f4 feat(client): Set Relays in the JS Client Config (#139)
* added js pubky client constructor config

* fixed bugs

* fmt and cargotoml

* moved wasm constructor order

* removed pubky-common reexport of client
2025-05-23 18:32:37 +03:00

35 lines
795 B
JavaScript

import test from 'tape'
import { Client } from '../index.cjs'
test('new Client() without config', async (t) => {
const client = new Client(); // Should always work
t.ok(client, "should create a client");
});
test('new Client() with config', async (t) => {
const client = new Client({
pkarr: {
relays: ['http://localhost:15412/relay'],
requestTimeout: 1000
},
userMaxRecordAge: 1000
});
t.ok(client, "should create a client");
});
test('new Client() partial config', async (t) => {
const client = new Client({
userMaxRecordAge: 1000
});
t.ok(client, "should create a client");
});
test('new Client() with faulty config', async (t) => {
t.throws(() => new Client({
userMaxRecordAge: 0 // Zero is invalid
}), "should throw an error");
});