You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.0 KiB
33 lines
1.0 KiB
import { ExtendedKind } from '@/constants' |
|
import { describe, expect, it } from 'vitest' |
|
import { parseProfileBadgeEntries, parseAddressableCoordinate } from './nip58-profile-badges' |
|
import type { Event } from 'nostr-tools' |
|
|
|
describe('parseProfileBadgeEntries', () => { |
|
it('pairs consecutive a and e tags', () => { |
|
const event = { |
|
kind: ExtendedKind.PROFILE_BADGES_LIST, |
|
tags: [ |
|
['a', '30009:alice:bravery'], |
|
['e', 'award1'], |
|
['a', '30009:alice:honor'], |
|
['e', 'award2'], |
|
['a', '30009:alice:orphan'] |
|
] |
|
} as Event |
|
expect(parseProfileBadgeEntries(event)).toEqual([ |
|
{ definitionCoordinate: '30009:alice:bravery', awardEventId: 'award1' }, |
|
{ definitionCoordinate: '30009:alice:honor', awardEventId: 'award2' } |
|
]) |
|
}) |
|
}) |
|
|
|
describe('parseAddressableCoordinate', () => { |
|
it('parses kind pubkey and d', () => { |
|
expect(parseAddressableCoordinate('30009:alice:bravery')).toEqual({ |
|
kind: 30009, |
|
pubkey: 'alice', |
|
d: 'bravery' |
|
}) |
|
}) |
|
})
|
|
|