forked from Kieran/snort
05605bdf28
* vastly simplify the api * add missing await * add eose to emitter * add eose to conn * add eose to the client * eose test * improve test suite, add dm tests * demonstrate that nostr-rs-relay auth options don't work * readme files * cleanup * fetch relay info * test readyState * export fetchRelayInfo * cleanup * better async/await linting * use strictEqual in tests * additional eslint rules * allow arbitrary extensions * saner error handling * update README * implement nip-02 --------- Co-authored-by: Kieran <kieran@harkin.me>
25 lines
580 B
TypeScript
25 lines
580 B
TypeScript
import assert from "assert"
|
|
import { Nostr } from "../src/client"
|
|
import { relayUrl } from "./setup"
|
|
|
|
describe("ready state", () => {
|
|
it("ready state transitions", (done) => {
|
|
const nostr = new Nostr()
|
|
|
|
nostr.on("error", done)
|
|
|
|
nostr.on("open", () => {
|
|
assert.strictEqual(nostr.relays[0].readyState, Nostr.OPEN)
|
|
nostr.close()
|
|
})
|
|
|
|
nostr.on("close", () => {
|
|
assert.strictEqual(nostr.relays[0].readyState, Nostr.CLOSED)
|
|
done()
|
|
})
|
|
|
|
nostr.open(relayUrl)
|
|
assert.strictEqual(nostr.relays[0].readyState, Nostr.CONNECTING)
|
|
})
|
|
})
|