@@ -1,11 +1,5 @@
|
||||
import {describe, it, expect} from "vitest"
|
||||
import {
|
||||
makeSecret,
|
||||
BOOKMARKS,
|
||||
NOTE,
|
||||
getEventTagValues,
|
||||
getTopicTagValues,
|
||||
} from "@welshman/util"
|
||||
import {makeSecret, BOOKMARKS, NOTE, getEventTagValues, getTopicTagValues} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {Nip01Signer} from "@welshman/signer"
|
||||
import {BookmarkList, BookmarkListBuilder} from "../src/kinds/BookmarkList"
|
||||
@@ -83,7 +77,12 @@ describe("BookmarkList", () => {
|
||||
})
|
||||
|
||||
it("removeBookmark removes by value", async () => {
|
||||
const event = makeEvent({tags: [["e", noteId], ["e", noteId2]]})
|
||||
const event = makeEvent({
|
||||
tags: [
|
||||
["e", noteId],
|
||||
["e", noteId2],
|
||||
],
|
||||
})
|
||||
const list = await BookmarkList.fromEvent(event)
|
||||
|
||||
const tmpl = await list.builder().removeBookmark(noteId).toTemplate(signer)
|
||||
|
||||
@@ -49,7 +49,14 @@ describe("Classified", () => {
|
||||
})
|
||||
|
||||
it("defaults the price currency to SAT", async () => {
|
||||
const c = await Classified.fromEvent(makeEvent({tags: [["d", "x"], ["price", "50"]]}))
|
||||
const c = await Classified.fromEvent(
|
||||
makeEvent({
|
||||
tags: [
|
||||
["d", "x"],
|
||||
["price", "50"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(c.price()).toEqual({amount: 50, currency: "SAT", frequency: ""})
|
||||
})
|
||||
|
||||
@@ -25,7 +25,12 @@ const makeEvent = (o: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("FeedList", () => {
|
||||
it("reads saved feed addresses", async () => {
|
||||
const reader = await FeedList.fromEvent(
|
||||
makeEvent({tags: [["a", addressA], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["a", addressA],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(reader.addresses()).toEqual([addressA])
|
||||
@@ -35,7 +40,12 @@ describe("FeedList", () => {
|
||||
|
||||
it("round-trips without duplicating represented tags", async () => {
|
||||
const reader = await FeedList.fromEvent(
|
||||
makeEvent({tags: [["a", addressA], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["a", addressA],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await reader.builder().toTemplate(signer)
|
||||
|
||||
@@ -69,7 +69,12 @@ describe("FollowList", () => {
|
||||
})
|
||||
|
||||
it("removeFollow removes by value", async () => {
|
||||
const event = makeEvent({tags: [["p", a], ["p", b]]})
|
||||
const event = makeEvent({
|
||||
tags: [
|
||||
["p", a],
|
||||
["p", b],
|
||||
],
|
||||
})
|
||||
const list = await FollowList.fromEvent(event)
|
||||
|
||||
const tmpl = await list.builder().removeFollow(a).toTemplate(signer)
|
||||
|
||||
@@ -9,7 +9,6 @@ const pubkey = "ee".repeat(32)
|
||||
|
||||
const g1 = `34550:${"aa".repeat(32)}:dev`
|
||||
const g2 = `34550:${"bb".repeat(32)}:art`
|
||||
const g3 = `34550:${"cc".repeat(32)}:music`
|
||||
|
||||
const makeEvent = (o: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
({
|
||||
@@ -67,7 +66,12 @@ describe("GroupList", () => {
|
||||
})
|
||||
|
||||
it("removeGroup removes by address", async () => {
|
||||
const event = makeEvent({tags: [["a", g1], ["a", g2]]})
|
||||
const event = makeEvent({
|
||||
tags: [
|
||||
["a", g1],
|
||||
["a", g2],
|
||||
],
|
||||
})
|
||||
const list = await GroupList.fromEvent(event)
|
||||
|
||||
const tmpl = await list.builder().removeGroup(g1).toTemplate(signer)
|
||||
|
||||
@@ -46,7 +46,12 @@ describe("HandlerRecommendation", () => {
|
||||
|
||||
it("falls back to the first recommendation without a web marker", async () => {
|
||||
const rec = await HandlerRecommendation.fromEvent(
|
||||
makeEvent({tags: [["d", "1"], ["a", otherAddress, "", "android"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["d", "1"],
|
||||
["a", otherAddress, "", "android"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(rec.handlerAddress()).toBe(otherAddress)
|
||||
|
||||
@@ -25,7 +25,13 @@ const makeEvent = (o: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("PinList", () => {
|
||||
it("reads pinned event ids and addresses", async () => {
|
||||
const reader = await PinList.fromEvent(
|
||||
makeEvent({tags: [["e", eventId], ["a", address], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["e", eventId],
|
||||
["a", address],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(reader.ids()).toEqual([eventId])
|
||||
@@ -34,7 +40,13 @@ describe("PinList", () => {
|
||||
|
||||
it("round-trips without duplicating represented tags", async () => {
|
||||
const reader = await PinList.fromEvent(
|
||||
makeEvent({tags: [["e", eventId], ["a", address], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["e", eventId],
|
||||
["a", address],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await reader.builder().toTemplate(signer)
|
||||
|
||||
@@ -23,13 +23,29 @@ const makeEvent = (overrides: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
|
||||
describe("RelayAddMember", () => {
|
||||
it("reads affected pubkeys, deduped", async () => {
|
||||
const op = await RelayAddMember.fromEvent(makeEvent({tags: [["p", a], ["p", b], ["p", a]]}))
|
||||
const op = await RelayAddMember.fromEvent(
|
||||
makeEvent({
|
||||
tags: [
|
||||
["p", a],
|
||||
["p", b],
|
||||
["p", a],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(op.pubkeys().sort()).toEqual([a, b].sort())
|
||||
})
|
||||
|
||||
it("round-trips with no duplicate p tags and passthrough", async () => {
|
||||
const op = await RelayAddMember.fromEvent(makeEvent({tags: [["p", a], ["p", b], ["alt", "x"]]}))
|
||||
const op = await RelayAddMember.fromEvent(
|
||||
makeEvent({
|
||||
tags: [
|
||||
["p", a],
|
||||
["p", b],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await op.builder().toTemplate(signer)
|
||||
|
||||
|
||||
@@ -38,7 +38,13 @@ describe("RelayJoin", () => {
|
||||
|
||||
it("round-trips with no duplicate tags and preserves passthrough/content", async () => {
|
||||
const join = await RelayJoin.fromEvent(
|
||||
makeEvent({tags: [["claim", "abc123"], ["alt", "x"]], content: "let me in"}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["claim", "abc123"],
|
||||
["alt", "x"],
|
||||
],
|
||||
content: "let me in",
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await join.builder().toTemplate(signer)
|
||||
|
||||
@@ -22,7 +22,14 @@ const makeEvent = (overrides: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
|
||||
describe("RelayLeave", () => {
|
||||
it("round-trips the group behavior tag without duplication", async () => {
|
||||
const leave = await RelayLeave.fromEvent(makeEvent({tags: [["h", group], ["alt", "x"]]}))
|
||||
const leave = await RelayLeave.fromEvent(
|
||||
makeEvent({
|
||||
tags: [
|
||||
["h", group],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(leave.group()).toBe(group)
|
||||
|
||||
|
||||
@@ -36,21 +36,19 @@ describe("RelayList", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
expect(reader.urls().sort()).toEqual(
|
||||
[both, read, write].map(normalizeRelayUrl).sort(),
|
||||
)
|
||||
expect(reader.readUrls().sort()).toEqual(
|
||||
[both, read].map(normalizeRelayUrl).sort(),
|
||||
)
|
||||
expect(reader.writeUrls().sort()).toEqual(
|
||||
[both, write].map(normalizeRelayUrl).sort(),
|
||||
)
|
||||
expect(reader.urls().sort()).toEqual([both, read, write].map(normalizeRelayUrl).sort())
|
||||
expect(reader.readUrls().sort()).toEqual([both, read].map(normalizeRelayUrl).sort())
|
||||
expect(reader.writeUrls().sort()).toEqual([both, write].map(normalizeRelayUrl).sort())
|
||||
})
|
||||
|
||||
it("round-trips without duplicating represented tags", async () => {
|
||||
const reader = await RelayList.fromEvent(
|
||||
makeEvent({
|
||||
tags: [["r", both], ["r", read, RelayMode.Read], ["alt", "x"]],
|
||||
tags: [
|
||||
["r", both],
|
||||
["r", read, RelayMode.Read],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
@@ -25,7 +25,13 @@ const makeEvent = (overrides: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("RelayMembers", () => {
|
||||
it("reads members from member tags", async () => {
|
||||
const members = await RelayMembers.fromEvent(
|
||||
makeEvent({tags: [["member", a], ["member", b], ["member", a]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["member", a],
|
||||
["member", b],
|
||||
["member", a],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(members.pubkeys().sort()).toEqual([a, b].sort())
|
||||
@@ -35,7 +41,13 @@ describe("RelayMembers", () => {
|
||||
|
||||
it("round-trips with deduped member tags and passthrough", async () => {
|
||||
const members = await RelayMembers.fromEvent(
|
||||
makeEvent({tags: [["member", a], ["member", b], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["member", a],
|
||||
["member", b],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await members.builder().toTemplate(signer)
|
||||
|
||||
@@ -89,7 +89,13 @@ describe("RelaySet", () => {
|
||||
|
||||
it("setRelays replaces relays but preserves metadata", async () => {
|
||||
const reader = await RelaySet.fromEvent(
|
||||
makeEvent({tags: [["d", "my-set"], ["title", "My Set"], ["relay", relayA]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["d", "my-set"],
|
||||
["title", "My Set"],
|
||||
["relay", relayA],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await reader.builder().setUrls([relayB]).toTemplate(signer)
|
||||
|
||||
@@ -24,7 +24,14 @@ const makeEvent = (overrides: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("RoomAddMember", () => {
|
||||
it("reads pubkeys and group", async () => {
|
||||
const op = await RoomAddMember.fromEvent(
|
||||
makeEvent({tags: [["h", "room1"], ["p", a], ["p", b], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["h", "room1"],
|
||||
["p", a],
|
||||
["p", b],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(op.kind).toBe(ROOM_ADD_MEMBER)
|
||||
@@ -34,7 +41,14 @@ describe("RoomAddMember", () => {
|
||||
|
||||
it("round-trips with no duplicated tags", async () => {
|
||||
const op = await RoomAddMember.fromEvent(
|
||||
makeEvent({tags: [["h", "room1"], ["p", a], ["p", b], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["h", "room1"],
|
||||
["p", a],
|
||||
["p", b],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await op.builder().toTemplate(signer)
|
||||
|
||||
@@ -24,7 +24,14 @@ const makeEvent = (overrides: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("RoomAdmins", () => {
|
||||
it("reads represented tags", async () => {
|
||||
const room = await RoomAdmins.fromEvent(
|
||||
makeEvent({tags: [["d", "room1"], ["p", a], ["p", b], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["d", "room1"],
|
||||
["p", a],
|
||||
["p", b],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(room.identifier()).toBe("room1")
|
||||
@@ -33,7 +40,14 @@ describe("RoomAdmins", () => {
|
||||
|
||||
it("round-trips with no duplicated tags", async () => {
|
||||
const room = await RoomAdmins.fromEvent(
|
||||
makeEvent({tags: [["d", "room1"], ["p", a], ["p", b], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["d", "room1"],
|
||||
["p", a],
|
||||
["p", b],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await room.builder().toTemplate(signer)
|
||||
|
||||
@@ -22,7 +22,14 @@ const makeEvent = (overrides: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
|
||||
describe("RoomCreate", () => {
|
||||
it("round-trips the group behavior tag without duplication", async () => {
|
||||
const create = await RoomCreate.fromEvent(makeEvent({tags: [["h", group], ["alt", "x"]]}))
|
||||
const create = await RoomCreate.fromEvent(
|
||||
makeEvent({
|
||||
tags: [
|
||||
["h", group],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(create.group()).toBe(group)
|
||||
|
||||
|
||||
@@ -2,10 +2,7 @@ import {describe, it, expect} from "vitest"
|
||||
import {makeSecret, ROOM_CREATE_PERMISSION, NOTE} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {Nip01Signer} from "@welshman/signer"
|
||||
import {
|
||||
RoomCreatePermission,
|
||||
RoomCreatePermissionBuilder,
|
||||
} from "../src/kinds/RoomCreatePermission"
|
||||
import {RoomCreatePermission, RoomCreatePermissionBuilder} from "../src/kinds/RoomCreatePermission"
|
||||
|
||||
const signer = new Nip01Signer(makeSecret())
|
||||
const pubkey = "ee".repeat(32)
|
||||
@@ -28,7 +25,13 @@ const makeEvent = (overrides: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("RoomCreatePermission", () => {
|
||||
it("reads permitted pubkeys from p tags", async () => {
|
||||
const perm = await RoomCreatePermission.fromEvent(
|
||||
makeEvent({tags: [["p", a], ["p", b], ["p", a]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["p", a],
|
||||
["p", b],
|
||||
["p", a],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(perm.pubkeys().sort()).toEqual([a, b].sort())
|
||||
@@ -38,7 +41,13 @@ describe("RoomCreatePermission", () => {
|
||||
|
||||
it("round-trips with no duplicate p tags and passthrough", async () => {
|
||||
const perm = await RoomCreatePermission.fromEvent(
|
||||
makeEvent({tags: [["p", a], ["p", b], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["p", a],
|
||||
["p", b],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await perm.builder().toTemplate(signer)
|
||||
|
||||
@@ -28,7 +28,14 @@ describe("RoomDelete", () => {
|
||||
})
|
||||
|
||||
it("round-trips the group behavior tag without duplication", async () => {
|
||||
const del = await RoomDelete.fromEvent(makeEvent({tags: [["h", group], ["alt", "x"]]}))
|
||||
const del = await RoomDelete.fromEvent(
|
||||
makeEvent({
|
||||
tags: [
|
||||
["h", group],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await del.builder().toTemplate(signer)
|
||||
|
||||
|
||||
@@ -23,7 +23,11 @@ describe("RoomJoin", () => {
|
||||
it("reads represented fields", async () => {
|
||||
const join = await RoomJoin.fromEvent(
|
||||
makeEvent({
|
||||
tags: [["h", "room1"], ["claim", "invite-code"], ["alt", "x"]],
|
||||
tags: [
|
||||
["h", "room1"],
|
||||
["claim", "invite-code"],
|
||||
["alt", "x"],
|
||||
],
|
||||
content: "please let me in",
|
||||
}),
|
||||
)
|
||||
@@ -36,7 +40,11 @@ describe("RoomJoin", () => {
|
||||
it("round-trips with no duplicated tags", async () => {
|
||||
const join = await RoomJoin.fromEvent(
|
||||
makeEvent({
|
||||
tags: [["h", "room1"], ["claim", "invite-code"], ["alt", "x"]],
|
||||
tags: [
|
||||
["h", "room1"],
|
||||
["claim", "invite-code"],
|
||||
["alt", "x"],
|
||||
],
|
||||
content: "please let me in",
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -28,7 +28,14 @@ describe("RoomLeave", () => {
|
||||
})
|
||||
|
||||
it("round-trips the group behavior tag without duplication", async () => {
|
||||
const leave = await RoomLeave.fromEvent(makeEvent({tags: [["h", group], ["alt", "x"]]}))
|
||||
const leave = await RoomLeave.fromEvent(
|
||||
makeEvent({
|
||||
tags: [
|
||||
["h", group],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await leave.builder().toTemplate(signer)
|
||||
|
||||
|
||||
@@ -26,7 +26,12 @@ const makeEvent = (o: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("RoomList", () => {
|
||||
it("reads joined groups", async () => {
|
||||
const reader = await RoomList.fromEvent(
|
||||
makeEvent({tags: [["group", groupA, relay], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["group", groupA, relay],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(reader.groups()).toEqual([groupA])
|
||||
@@ -35,7 +40,12 @@ describe("RoomList", () => {
|
||||
|
||||
it("round-trips without duplicating represented tags", async () => {
|
||||
const reader = await RoomList.fromEvent(
|
||||
makeEvent({tags: [["group", groupA, relay], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["group", groupA, relay],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await reader.builder().toTemplate(signer)
|
||||
|
||||
@@ -25,7 +25,14 @@ const makeEvent = (overrides: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("RoomMembers", () => {
|
||||
it("reads represented tags", async () => {
|
||||
const room = await RoomMembers.fromEvent(
|
||||
makeEvent({tags: [["d", "room1"], ["p", a], ["p", b], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["d", "room1"],
|
||||
["p", a],
|
||||
["p", b],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(room.identifier()).toBe("room1")
|
||||
@@ -36,7 +43,14 @@ describe("RoomMembers", () => {
|
||||
|
||||
it("round-trips with no duplicated tags", async () => {
|
||||
const room = await RoomMembers.fromEvent(
|
||||
makeEvent({tags: [["d", "room1"], ["p", a], ["p", b], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["d", "room1"],
|
||||
["p", a],
|
||||
["p", b],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await room.builder().toTemplate(signer)
|
||||
|
||||
@@ -23,7 +23,14 @@ const makeEvent = (overrides: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
|
||||
describe("RoomRemoveMember", () => {
|
||||
it("uses the remove kind and reads pubkeys", async () => {
|
||||
const op = await RoomRemoveMember.fromEvent(makeEvent({tags: [["h", "room1"], ["p", a]]}))
|
||||
const op = await RoomRemoveMember.fromEvent(
|
||||
makeEvent({
|
||||
tags: [
|
||||
["h", "room1"],
|
||||
["p", a],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(op.kind).toBe(ROOM_REMOVE_MEMBER)
|
||||
expect(op.pubkeys()).toEqual([a])
|
||||
@@ -31,7 +38,13 @@ describe("RoomRemoveMember", () => {
|
||||
|
||||
it("round-trips through the remove builder", async () => {
|
||||
const op = await RoomRemoveMember.fromEvent(
|
||||
makeEvent({tags: [["h", "room1"], ["p", a], ["p", b]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["h", "room1"],
|
||||
["p", a],
|
||||
["p", b],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await op.builder().toTemplate(signer)
|
||||
@@ -43,7 +56,10 @@ describe("RoomRemoveMember", () => {
|
||||
})
|
||||
|
||||
it("builds from a fresh remove builder", async () => {
|
||||
const tmpl = await new RoomRemoveMemberBuilder().setGroup("room2").addPubkey(a).toTemplate(signer)
|
||||
const tmpl = await new RoomRemoveMemberBuilder()
|
||||
.setGroup("room2")
|
||||
.addPubkey(a)
|
||||
.toTemplate(signer)
|
||||
|
||||
expect(tmpl.kind).toBe(ROOM_REMOVE_MEMBER)
|
||||
expect(getTagValue("h", tmpl.tags)).toBe("room2")
|
||||
|
||||
@@ -25,7 +25,12 @@ const makeEvent = (o: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("SearchRelayList", () => {
|
||||
it("reads search relay urls", async () => {
|
||||
const reader = await SearchRelayList.fromEvent(
|
||||
makeEvent({tags: [["relay", relayA], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["relay", relayA],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(reader.urls()).toEqual([normalizeRelayUrl(relayA)])
|
||||
@@ -35,7 +40,12 @@ describe("SearchRelayList", () => {
|
||||
|
||||
it("round-trips without duplicating represented tags", async () => {
|
||||
const reader = await SearchRelayList.fromEvent(
|
||||
makeEvent({tags: [["relay", relayA], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["relay", relayA],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await reader.builder().toTemplate(signer)
|
||||
|
||||
@@ -26,7 +26,13 @@ const makeEvent = (o: Partial<TrustedEvent> = {}): TrustedEvent =>
|
||||
describe("TopicList", () => {
|
||||
it("reads followed topics and interest-set addresses", async () => {
|
||||
const reader = await TopicList.fromEvent(
|
||||
makeEvent({tags: [["t", topicA], ["a", address], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["t", topicA],
|
||||
["a", address],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(reader.topics()).toEqual([topicA])
|
||||
@@ -37,7 +43,13 @@ describe("TopicList", () => {
|
||||
|
||||
it("round-trips without duplicating represented tags", async () => {
|
||||
const reader = await TopicList.fromEvent(
|
||||
makeEvent({tags: [["t", topicA], ["a", address], ["alt", "x"]]}),
|
||||
makeEvent({
|
||||
tags: [
|
||||
["t", topicA],
|
||||
["a", address],
|
||||
["alt", "x"],
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
const tmpl = await reader.builder().toTemplate(signer)
|
||||
|
||||
Reference in New Issue
Block a user