run prettier on tests.
This commit is contained in:
parent
03cc18d53b
commit
5d92be05bb
|
@ -6,38 +6,39 @@ const relayUrl = 'https://relay.example.com'
|
|||
|
||||
describe('finishRepostEvent + getRepostedEventPointer + getRepostedEvent', () => {
|
||||
const privateKey =
|
||||
'd217c1ff2f8a65c3e3a1740db3b9f58b8c848bb45e26d00ed4714e4a0f4ceecf'
|
||||
'd217c1ff2f8a65c3e3a1740db3b9f58b8c848bb45e26d00ed4714e4a0f4ceecf'
|
||||
|
||||
const publicKey = getPublicKey(privateKey)
|
||||
|
||||
const repostedEvent = finishEvent({
|
||||
kind: Kind.Text,
|
||||
tags: [
|
||||
['e', 'replied event id'],
|
||||
['p', 'replied event pubkey'],
|
||||
],
|
||||
content: 'Replied to a post',
|
||||
created_at: 1617932115
|
||||
}, privateKey)
|
||||
const repostedEvent = finishEvent(
|
||||
{
|
||||
kind: Kind.Text,
|
||||
tags: [
|
||||
['e', 'replied event id'],
|
||||
['p', 'replied event pubkey']
|
||||
],
|
||||
content: 'Replied to a post',
|
||||
created_at: 1617932115
|
||||
},
|
||||
privateKey
|
||||
)
|
||||
|
||||
it('should create a signed event from a minimal template', () => {
|
||||
const template = {
|
||||
created_at: 1617932115
|
||||
}
|
||||
|
||||
const event = nip18.finishRepostEvent(template, repostedEvent, relayUrl, privateKey)
|
||||
const event = nip18.finishRepostEvent(
|
||||
template,
|
||||
repostedEvent,
|
||||
relayUrl,
|
||||
privateKey
|
||||
)
|
||||
|
||||
expect(event.kind).toEqual(Kind.Repost)
|
||||
expect(event.tags).toEqual([
|
||||
[
|
||||
'e',
|
||||
repostedEvent.id,
|
||||
relayUrl,
|
||||
],
|
||||
[
|
||||
'p',
|
||||
repostedEvent.pubkey,
|
||||
],
|
||||
['e', repostedEvent.id, relayUrl],
|
||||
['p', repostedEvent.pubkey]
|
||||
])
|
||||
expect(event.content).toEqual(JSON.stringify(repostedEvent))
|
||||
expect(event.created_at).toEqual(template.created_at)
|
||||
|
@ -49,7 +50,7 @@ describe('finishRepostEvent + getRepostedEventPointer + getRepostedEvent', () =>
|
|||
|
||||
expect(repostedEventPointer.id).toEqual(repostedEvent.id)
|
||||
expect(repostedEventPointer.author).toEqual(repostedEvent.pubkey)
|
||||
expect(repostedEventPointer.relays).toEqual([ relayUrl ])
|
||||
expect(repostedEventPointer.relays).toEqual([relayUrl])
|
||||
|
||||
const repostedEventFromContent = nip18.getRepostedEvent(event)
|
||||
|
||||
|
@ -58,30 +59,23 @@ describe('finishRepostEvent + getRepostedEventPointer + getRepostedEvent', () =>
|
|||
|
||||
it('should create a signed event from a filled template', () => {
|
||||
const template = {
|
||||
tags: [
|
||||
['nonstandard', 'tag'],
|
||||
],
|
||||
tags: [['nonstandard', 'tag']],
|
||||
content: '',
|
||||
created_at: 1617932115
|
||||
}
|
||||
|
||||
const event = nip18.finishRepostEvent(template, repostedEvent, relayUrl, privateKey)
|
||||
const event = nip18.finishRepostEvent(
|
||||
template,
|
||||
repostedEvent,
|
||||
relayUrl,
|
||||
privateKey
|
||||
)
|
||||
|
||||
expect(event.kind).toEqual(Kind.Repost)
|
||||
expect(event.tags).toEqual([
|
||||
[
|
||||
'nonstandard',
|
||||
'tag',
|
||||
],
|
||||
[
|
||||
'e',
|
||||
repostedEvent.id,
|
||||
relayUrl,
|
||||
],
|
||||
[
|
||||
'p',
|
||||
repostedEvent.pubkey,
|
||||
],
|
||||
['nonstandard', 'tag'],
|
||||
['e', repostedEvent.id, relayUrl],
|
||||
['p', repostedEvent.pubkey]
|
||||
])
|
||||
expect(event.content).toEqual('')
|
||||
expect(event.created_at).toEqual(template.created_at)
|
||||
|
@ -93,7 +87,7 @@ describe('finishRepostEvent + getRepostedEventPointer + getRepostedEvent', () =>
|
|||
|
||||
expect(repostedEventPointer.id).toEqual(repostedEvent.id)
|
||||
expect(repostedEventPointer.author).toEqual(repostedEvent.pubkey)
|
||||
expect(repostedEventPointer.relays).toEqual([ relayUrl ])
|
||||
expect(repostedEventPointer.relays).toEqual([relayUrl])
|
||||
|
||||
const repostedEventFromContent = nip18.getRepostedEvent(event)
|
||||
|
||||
|
@ -105,15 +99,13 @@ describe('getRepostedEventPointer', () => {
|
|||
it('should parse an event with only an `e` tag', () => {
|
||||
const event = {
|
||||
kind: Kind.Repost,
|
||||
tags: [
|
||||
['e', 'reposted event id', relayUrl],
|
||||
],
|
||||
tags: [['e', 'reposted event id', relayUrl]]
|
||||
}
|
||||
|
||||
const repostedEventPointer = nip18.getRepostedEventPointer(event)
|
||||
|
||||
expect(repostedEventPointer.id).toEqual('reposted event id')
|
||||
expect(repostedEventPointer.author).toEqual(undefined)
|
||||
expect(repostedEventPointer.relays).toEqual([ relayUrl ])
|
||||
expect(repostedEventPointer.relays).toEqual([relayUrl])
|
||||
})
|
||||
})
|
||||
|
|
|
@ -102,7 +102,7 @@ test('decode naddr from go-nostr with different TLV ordering', () => {
|
|||
})
|
||||
|
||||
test('encode and decode nrelay', () => {
|
||||
let url = "wss://relay.nostr.example"
|
||||
let url = 'wss://relay.nostr.example'
|
||||
let nrelay = nip19.nrelayEncode(url)
|
||||
expect(nrelay).toMatch(/nrelay1\w+/)
|
||||
let {type, data} = nip19.decode(nrelay)
|
||||
|
|
|
@ -4,19 +4,22 @@ const {nip25, finishEvent, getPublicKey, Kind} = require('./lib/nostr.cjs')
|
|||
|
||||
describe('finishReactionEvent + getReactedEventPointer', () => {
|
||||
const privateKey =
|
||||
'd217c1ff2f8a65c3e3a1740db3b9f58b8c848bb45e26d00ed4714e4a0f4ceecf'
|
||||
'd217c1ff2f8a65c3e3a1740db3b9f58b8c848bb45e26d00ed4714e4a0f4ceecf'
|
||||
|
||||
const publicKey = getPublicKey(privateKey)
|
||||
|
||||
const reactedEvent = finishEvent({
|
||||
kind: Kind.Text,
|
||||
tags: [
|
||||
['e', 'replied event id'],
|
||||
['p', 'replied event pubkey'],
|
||||
],
|
||||
content: 'Replied to a post',
|
||||
created_at: 1617932115
|
||||
}, privateKey)
|
||||
const reactedEvent = finishEvent(
|
||||
{
|
||||
kind: Kind.Text,
|
||||
tags: [
|
||||
['e', 'replied event id'],
|
||||
['p', 'replied event pubkey']
|
||||
],
|
||||
content: 'Replied to a post',
|
||||
created_at: 1617932115
|
||||
},
|
||||
privateKey
|
||||
)
|
||||
|
||||
it('should create a signed event from a minimal template', () => {
|
||||
const template = {
|
||||
|
@ -27,22 +30,10 @@ describe('finishReactionEvent + getReactedEventPointer', () => {
|
|||
|
||||
expect(event.kind).toEqual(Kind.Reaction)
|
||||
expect(event.tags).toEqual([
|
||||
[
|
||||
'e',
|
||||
'replied event id',
|
||||
],
|
||||
[
|
||||
'p',
|
||||
'replied event pubkey',
|
||||
],
|
||||
[
|
||||
'e',
|
||||
'0ecdbd4dba0652afb19e5f638257a41552a37995a4438ef63de658443f8d16b1',
|
||||
],
|
||||
[
|
||||
'p',
|
||||
'6af0f9de588f2c53cedcba26c5e2402e0d0aa64ec7b47c9f8d97b5bc562bab5f',
|
||||
],
|
||||
['e', 'replied event id'],
|
||||
['p', 'replied event pubkey'],
|
||||
['e', '0ecdbd4dba0652afb19e5f638257a41552a37995a4438ef63de658443f8d16b1'],
|
||||
['p', '6af0f9de588f2c53cedcba26c5e2402e0d0aa64ec7b47c9f8d97b5bc562bab5f']
|
||||
])
|
||||
expect(event.content).toEqual('+')
|
||||
expect(event.created_at).toEqual(template.created_at)
|
||||
|
@ -58,9 +49,7 @@ describe('finishReactionEvent + getReactedEventPointer', () => {
|
|||
|
||||
it('should create a signed event from a filled template', () => {
|
||||
const template = {
|
||||
tags: [
|
||||
['nonstandard', 'tag'],
|
||||
],
|
||||
tags: [['nonstandard', 'tag']],
|
||||
content: '👍',
|
||||
created_at: 1617932115
|
||||
}
|
||||
|
@ -69,26 +58,11 @@ describe('finishReactionEvent + getReactedEventPointer', () => {
|
|||
|
||||
expect(event.kind).toEqual(Kind.Reaction)
|
||||
expect(event.tags).toEqual([
|
||||
[
|
||||
'nonstandard',
|
||||
'tag',
|
||||
],
|
||||
[
|
||||
'e',
|
||||
'replied event id',
|
||||
],
|
||||
[
|
||||
'p',
|
||||
'replied event pubkey',
|
||||
],
|
||||
[
|
||||
'e',
|
||||
'0ecdbd4dba0652afb19e5f638257a41552a37995a4438ef63de658443f8d16b1',
|
||||
],
|
||||
[
|
||||
'p',
|
||||
'6af0f9de588f2c53cedcba26c5e2402e0d0aa64ec7b47c9f8d97b5bc562bab5f',
|
||||
],
|
||||
['nonstandard', 'tag'],
|
||||
['e', 'replied event id'],
|
||||
['p', 'replied event pubkey'],
|
||||
['e', '0ecdbd4dba0652afb19e5f638257a41552a37995a4438ef63de658443f8d16b1'],
|
||||
['p', '6af0f9de588f2c53cedcba26c5e2402e0d0aa64ec7b47c9f8d97b5bc562bab5f']
|
||||
])
|
||||
expect(event.content).toEqual('👍')
|
||||
expect(event.created_at).toEqual(template.created_at)
|
||||
|
|
Loading…
Reference in New Issue