fix the test
This commit is contained in:
parent
c20dea1dba
commit
6daa75b21c
@ -1,6 +1,5 @@
|
||||
import Base from "events"
|
||||
import { Nostr, SubscriptionId } from "."
|
||||
import { RawEvent, SignedEvent } from "../event"
|
||||
import { EventParams, Nostr } from "."
|
||||
|
||||
/**
|
||||
* Overrides providing better types for EventEmitter methods.
|
||||
@ -144,9 +143,3 @@ type Listener =
|
||||
| EventListener
|
||||
| NoticeListener
|
||||
| ErrorListener
|
||||
|
||||
interface EventParams {
|
||||
signed: SignedEvent
|
||||
subscriptionId: SubscriptionId
|
||||
raw: RawEvent
|
||||
}
|
||||
|
@ -295,3 +295,10 @@ export interface Filters {
|
||||
until?: Date
|
||||
limit?: number
|
||||
}
|
||||
|
||||
// TODO Document this
|
||||
export interface EventParams {
|
||||
signed: SignedEvent
|
||||
subscriptionId: SubscriptionId
|
||||
raw: RawEvent
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Nostr } from "../src/client"
|
||||
import { EventParams, Nostr } from "../src/client"
|
||||
import { EventKind } from "../src/event"
|
||||
import { PrivateKey } from "../src/keypair"
|
||||
import assert from "assert"
|
||||
@ -20,7 +20,7 @@ describe("single event communication", function () {
|
||||
const subscriber = new Nostr()
|
||||
subscriber.open("ws://localhost:12648")
|
||||
|
||||
subscriber.on("event", ({ signed: { event } }) => {
|
||||
function listener({ signed: { event } }: EventParams) {
|
||||
assert.equal(event.kind, EventKind.TextNote)
|
||||
assert.equal(event.pubkey.toString(), pubkey.toString())
|
||||
assert.equal(event.createdAt.toString(), timestamp.toString())
|
||||
@ -32,13 +32,15 @@ describe("single event communication", function () {
|
||||
// subscribe happen at the same time, the same event might end up being broadcast twice.
|
||||
// To prevent reacting to the same event and calling done() twice, remove the callback
|
||||
// for future events.
|
||||
subscriber.on("event", null)
|
||||
subscriber.off("event", listener)
|
||||
|
||||
publisher.close()
|
||||
subscriber.close()
|
||||
|
||||
done()
|
||||
})
|
||||
}
|
||||
|
||||
subscriber.on("event", listener)
|
||||
|
||||
subscriber.subscribe([])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user