From 82caa2aad94cdea299b10abaf70e2d4e9f866619 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 10 May 2023 16:20:27 -0500 Subject: [PATCH] Use buildEvent function in more places --- nip18.test.ts | 10 +++------- nip26.test.ts | 9 +++------ references.test.ts | 10 +++------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/nip18.test.ts b/nip18.test.ts index 0ca4ae0..5fd5a5d 100644 --- a/nip18.test.ts +++ b/nip18.test.ts @@ -1,4 +1,5 @@ import {nip18, finishEvent, getPublicKey, Kind} from '.' +import { buildEvent } from './test-helpers' const relayUrl = 'https://relay.example.com' @@ -95,15 +96,10 @@ describe('finishRepostEvent + getRepostedEventPointer + getRepostedEvent', () => describe('getRepostedEventPointer', () => { it('should parse an event with only an `e` tag', () => { - const event = { + const event = buildEvent({ kind: Kind.Repost, tags: [['e', 'reposted event id', relayUrl]], - content: '', - created_at: 0, - pubkey: '', - id: '', - sig: '', - } + }) const repostedEventPointer = nip18.getRepostedEventPointer(event) diff --git a/nip26.test.ts b/nip26.test.ts index 5da6066..0334315 100644 --- a/nip26.test.ts +++ b/nip26.test.ts @@ -1,4 +1,5 @@ import {nip26, getPublicKey, generatePrivateKey} from '.' +import { buildEvent } from './test-helpers' test('parse good delegation from NIP', async () => { expect( @@ -94,14 +95,10 @@ test('create and verify delegation', async () => { expect(delegation).toHaveProperty('to', pk2) expect(delegation).toHaveProperty('cond', 'kind=1') - let event = { + let event = buildEvent({ kind: 1, tags: [['delegation', delegation.from, delegation.cond, delegation.sig]], pubkey: pk2, - content: '', - created_at: 0, - id: '', - sig: '', - } + }) expect(nip26.getDelegator(event)).toEqual(pk1) }) diff --git a/references.test.ts b/references.test.ts index 8ab773e..15f804e 100644 --- a/references.test.ts +++ b/references.test.ts @@ -1,10 +1,8 @@ import {parseReferences} from '.' +import { buildEvent } from './test-helpers' test('parse mentions', () => { - let evt = { - kind: 1, - id: '', - pubkey: '', + let evt = buildEvent({ tags: [ [ 'p', @@ -25,9 +23,7 @@ test('parse mentions', () => { ], content: '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([ {