mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 16:48:50 +00:00
Use buildEvent function in more places
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import {nip18, finishEvent, getPublicKey, Kind} from '.'
|
import {nip18, finishEvent, getPublicKey, Kind} from '.'
|
||||||
|
import { buildEvent } from './test-helpers'
|
||||||
|
|
||||||
const relayUrl = 'https://relay.example.com'
|
const relayUrl = 'https://relay.example.com'
|
||||||
|
|
||||||
@@ -95,15 +96,10 @@ describe('finishRepostEvent + getRepostedEventPointer + getRepostedEvent', () =>
|
|||||||
|
|
||||||
describe('getRepostedEventPointer', () => {
|
describe('getRepostedEventPointer', () => {
|
||||||
it('should parse an event with only an `e` tag', () => {
|
it('should parse an event with only an `e` tag', () => {
|
||||||
const event = {
|
const event = buildEvent({
|
||||||
kind: Kind.Repost,
|
kind: Kind.Repost,
|
||||||
tags: [['e', 'reposted event id', relayUrl]],
|
tags: [['e', 'reposted event id', relayUrl]],
|
||||||
content: '',
|
})
|
||||||
created_at: 0,
|
|
||||||
pubkey: '',
|
|
||||||
id: '',
|
|
||||||
sig: '',
|
|
||||||
}
|
|
||||||
|
|
||||||
const repostedEventPointer = nip18.getRepostedEventPointer(event)
|
const repostedEventPointer = nip18.getRepostedEventPointer(event)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {nip26, getPublicKey, generatePrivateKey} from '.'
|
import {nip26, getPublicKey, generatePrivateKey} from '.'
|
||||||
|
import { buildEvent } from './test-helpers'
|
||||||
|
|
||||||
test('parse good delegation from NIP', async () => {
|
test('parse good delegation from NIP', async () => {
|
||||||
expect(
|
expect(
|
||||||
@@ -94,14 +95,10 @@ test('create and verify delegation', async () => {
|
|||||||
expect(delegation).toHaveProperty('to', pk2)
|
expect(delegation).toHaveProperty('to', pk2)
|
||||||
expect(delegation).toHaveProperty('cond', 'kind=1')
|
expect(delegation).toHaveProperty('cond', 'kind=1')
|
||||||
|
|
||||||
let event = {
|
let event = buildEvent({
|
||||||
kind: 1,
|
kind: 1,
|
||||||
tags: [['delegation', delegation.from, delegation.cond, delegation.sig]],
|
tags: [['delegation', delegation.from, delegation.cond, delegation.sig]],
|
||||||
pubkey: pk2,
|
pubkey: pk2,
|
||||||
content: '',
|
})
|
||||||
created_at: 0,
|
|
||||||
id: '',
|
|
||||||
sig: '',
|
|
||||||
}
|
|
||||||
expect(nip26.getDelegator(event)).toEqual(pk1)
|
expect(nip26.getDelegator(event)).toEqual(pk1)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import {parseReferences} from '.'
|
import {parseReferences} from '.'
|
||||||
|
import { buildEvent } from './test-helpers'
|
||||||
|
|
||||||
test('parse mentions', () => {
|
test('parse mentions', () => {
|
||||||
let evt = {
|
let evt = buildEvent({
|
||||||
kind: 1,
|
|
||||||
id: '',
|
|
||||||
pubkey: '',
|
|
||||||
tags: [
|
tags: [
|
||||||
[
|
[
|
||||||
'p',
|
'p',
|
||||||
@@ -25,9 +23,7 @@ test('parse mentions', () => {
|
|||||||
],
|
],
|
||||||
content:
|
content:
|
||||||
'hello #[0], have you seen #[2]? it was made by nostr:nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg on nostr:nevent1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8ychxp5v4! broken #[3]',
|
'hello #[0], have you seen #[2]? it was made by nostr:nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg on nostr:nevent1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8ychxp5v4! broken #[3]',
|
||||||
created_at: 0,
|
})
|
||||||
sig: '',
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(parseReferences(evt)).toEqual([
|
expect(parseReferences(evt)).toEqual([
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user