fix: move NostrTypeGuard tests to nip19.test.ts
NostrTypeGuard was moved to nip19.ts in commit 45b25c5bf5
but tests stayed in core.test.ts and started failing because it still imported
NostrTypeGuard from core.ts - which wasn't there.
This commit is contained in:
parent
7064e0b828
commit
1b236faa7b
152
core.test.ts
152
core.test.ts
|
@ -1,5 +1,5 @@
|
|||
import { test, expect } from 'bun:test'
|
||||
import { NostrTypeGuard, sortEvents } from './core.ts'
|
||||
import { sortEvents } from './core.ts'
|
||||
|
||||
test('sortEvents', () => {
|
||||
const events = [
|
||||
|
@ -16,153 +16,3 @@ test('sortEvents', () => {
|
|||
{ id: 'abc123', pubkey: 'key1', created_at: 1610000000, kind: 1, tags: [], content: 'Hello', sig: 'sig1' },
|
||||
])
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNProfile', () => {
|
||||
const is = NostrTypeGuard.isNProfile('nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNProfile invalid nprofile', () => {
|
||||
const is = NostrTypeGuard.isNProfile('nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxãg')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNProfile with invalid nprofile', () => {
|
||||
const is = NostrTypeGuard.isNProfile('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juv')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNRelay', () => {
|
||||
const is = NostrTypeGuard.isNRelay('nrelay1qqt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueq4r295t')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNRelay with invalid nrelay', () => {
|
||||
const is = NostrTypeGuard.isNRelay('nrelay1qqt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueã4r295t')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNRelay with invalid nrelay', () => {
|
||||
const is = NostrTypeGuard.isNRelay(
|
||||
'nevent1qqst8cujky046negxgwwm5ynqwn53t8aqjr6afd8g59nfqwxpdhylpcpzamhxue69uhhyetvv9ujuetcv9khqmr99e3k7mg8arnc9',
|
||||
)
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNEvent', () => {
|
||||
const is = NostrTypeGuard.isNEvent(
|
||||
'nevent1qqst8cujky046negxgwwm5ynqwn53t8aqjr6afd8g59nfqwxpdhylpcpzamhxue69uhhyetvv9ujuetcv9khqmr99e3k7mg8arnc9',
|
||||
)
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNEvent with invalid nevent', () => {
|
||||
const is = NostrTypeGuard.isNEvent(
|
||||
'nevent1qqst8cujky046negxgwwm5ynqwn53t8aqjr6afd8g59nfqwxpdhylpcpzamhxue69uhhyetvv9ujuetcv9khqmr99e3k7mg8ãrnc9',
|
||||
)
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNEvent with invalid nevent', () => {
|
||||
const is = NostrTypeGuard.isNEvent('nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNAddr', () => {
|
||||
const is = NostrTypeGuard.isNAddr(
|
||||
'naddr1qqxnzdesxqmnxvpexqunzvpcqyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqzypve7elhmamff3sr5mgxxms4a0rppkmhmn7504h96pfcdkpplvl2jqcyqqq823cnmhuld',
|
||||
)
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNAddr with invalid nadress', () => {
|
||||
const is = NostrTypeGuard.isNAddr('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juv')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNSec', () => {
|
||||
const is = NostrTypeGuard.isNSec('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juv')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNSec with invalid nsec', () => {
|
||||
const is = NostrTypeGuard.isNSec('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juã')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNSec with invalid nsec', () => {
|
||||
const is = NostrTypeGuard.isNSec('nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNPub', () => {
|
||||
const is = NostrTypeGuard.isNPub('npub1jz5mdljkmffmqjshpyjgqgrhdkuxd9ztzasv8xeh5q92fv33sjgqy4pats')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNPub with invalid npub', () => {
|
||||
const is = NostrTypeGuard.isNPub('npub1jz5mdljkmffmqjshpyjgqgrhdkuxd9ztzãsv8xeh5q92fv33sjgqy4pats')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNPub with invalid npub', () => {
|
||||
const is = NostrTypeGuard.isNPub('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juv')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNote', () => {
|
||||
const is = NostrTypeGuard.isNote('note1gmtnz6q2m55epmlpe3semjdcq987av3jvx4emmjsa8g3s9x7tg4sclreky')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNote with invalid note', () => {
|
||||
const is = NostrTypeGuard.isNote('note1gmtnz6q2m55epmlpe3semjdcq987av3jvx4emmjsa8g3s9x7tg4sçlreky')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNote with invalid note', () => {
|
||||
const is = NostrTypeGuard.isNote('npub1jz5mdljkmffmqjshpyjgqgrhdkuxd9ztzasv8xeh5q92fv33sjgqy4pats')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNcryptsec', () => {
|
||||
const is = NostrTypeGuard.isNcryptsec(
|
||||
'ncryptsec1qgg9947rlpvqu76pj5ecreduf9jxhselq2nae2kghhvd5g7dgjtcxfqtd67p9m0w57lspw8gsq6yphnm8623nsl8xn9j4jdzz84zm3frztj3z7s35vpzmqf6ksu8r89qk5z2zxfmu5gv8th8wclt0h4p',
|
||||
)
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNcryptsec with invalid ncrytpsec', () => {
|
||||
const is = NostrTypeGuard.isNcryptsec(
|
||||
'ncryptsec1qgg9947rlpvqu76pj5ecreduf9jxhselq2nae2kghhvd5g7dgjtcxfqtd67p9m0w57lspw8gsq6yphnm8623nsã8xn9j4jdzz84zm3frztj3z7s35vpzmqf6ksu8r89qk5z2zxfmu5gv8th8wclt0h4p',
|
||||
)
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNcryptsec with invalid ncrytpsec', () => {
|
||||
const is = NostrTypeGuard.isNcryptsec('note1gmtnz6q2m55epmlpe3semjdcq987av3jvx4emmjsa8g3s9x7tg4sçlreky')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
|
152
nip19.test.ts
152
nip19.test.ts
|
@ -10,6 +10,7 @@ import {
|
|||
type AddressPointer,
|
||||
type ProfilePointer,
|
||||
EventPointer,
|
||||
NostrTypeGuard,
|
||||
} from './nip19.ts'
|
||||
|
||||
test('encode and decode nsec', () => {
|
||||
|
@ -151,3 +152,154 @@ test('decode naddr from go-nostr with different TLV ordering', () => {
|
|||
expect(pointer.kind).toEqual(30023)
|
||||
expect(pointer.identifier).toEqual('banana')
|
||||
})
|
||||
|
||||
|
||||
test('NostrTypeGuard isNProfile', () => {
|
||||
const is = NostrTypeGuard.isNProfile('nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNProfile invalid nprofile', () => {
|
||||
const is = NostrTypeGuard.isNProfile('nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxãg')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNProfile with invalid nprofile', () => {
|
||||
const is = NostrTypeGuard.isNProfile('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juv')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNRelay', () => {
|
||||
const is = NostrTypeGuard.isNRelay('nrelay1qqt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueq4r295t')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNRelay with invalid nrelay', () => {
|
||||
const is = NostrTypeGuard.isNRelay('nrelay1qqt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueã4r295t')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNRelay with invalid nrelay', () => {
|
||||
const is = NostrTypeGuard.isNRelay(
|
||||
'nevent1qqst8cujky046negxgwwm5ynqwn53t8aqjr6afd8g59nfqwxpdhylpcpzamhxue69uhhyetvv9ujuetcv9khqmr99e3k7mg8arnc9',
|
||||
)
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNEvent', () => {
|
||||
const is = NostrTypeGuard.isNEvent(
|
||||
'nevent1qqst8cujky046negxgwwm5ynqwn53t8aqjr6afd8g59nfqwxpdhylpcpzamhxue69uhhyetvv9ujuetcv9khqmr99e3k7mg8arnc9',
|
||||
)
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNEvent with invalid nevent', () => {
|
||||
const is = NostrTypeGuard.isNEvent(
|
||||
'nevent1qqst8cujky046negxgwwm5ynqwn53t8aqjr6afd8g59nfqwxpdhylpcpzamhxue69uhhyetvv9ujuetcv9khqmr99e3k7mg8ãrnc9',
|
||||
)
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNEvent with invalid nevent', () => {
|
||||
const is = NostrTypeGuard.isNEvent('nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNAddr', () => {
|
||||
const is = NostrTypeGuard.isNAddr(
|
||||
'naddr1qqxnzdesxqmnxvpexqunzvpcqyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqzypve7elhmamff3sr5mgxxms4a0rppkmhmn7504h96pfcdkpplvl2jqcyqqq823cnmhuld',
|
||||
)
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNAddr with invalid nadress', () => {
|
||||
const is = NostrTypeGuard.isNAddr('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juv')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNSec', () => {
|
||||
const is = NostrTypeGuard.isNSec('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juv')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNSec with invalid nsec', () => {
|
||||
const is = NostrTypeGuard.isNSec('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juã')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNSec with invalid nsec', () => {
|
||||
const is = NostrTypeGuard.isNSec('nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNPub', () => {
|
||||
const is = NostrTypeGuard.isNPub('npub1jz5mdljkmffmqjshpyjgqgrhdkuxd9ztzasv8xeh5q92fv33sjgqy4pats')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNPub with invalid npub', () => {
|
||||
const is = NostrTypeGuard.isNPub('npub1jz5mdljkmffmqjshpyjgqgrhdkuxd9ztzãsv8xeh5q92fv33sjgqy4pats')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNPub with invalid npub', () => {
|
||||
const is = NostrTypeGuard.isNPub('nsec1lqw6zqyanj9mz8gwhdam6tqge42vptz4zg93qsfej440xm5h5esqya0juv')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNote', () => {
|
||||
const is = NostrTypeGuard.isNote('note1gmtnz6q2m55epmlpe3semjdcq987av3jvx4emmjsa8g3s9x7tg4sclreky')
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNote with invalid note', () => {
|
||||
const is = NostrTypeGuard.isNote('note1gmtnz6q2m55epmlpe3semjdcq987av3jvx4emmjsa8g3s9x7tg4sçlreky')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNote with invalid note', () => {
|
||||
const is = NostrTypeGuard.isNote('npub1jz5mdljkmffmqjshpyjgqgrhdkuxd9ztzasv8xeh5q92fv33sjgqy4pats')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNcryptsec', () => {
|
||||
const is = NostrTypeGuard.isNcryptsec(
|
||||
'ncryptsec1qgg9947rlpvqu76pj5ecreduf9jxhselq2nae2kghhvd5g7dgjtcxfqtd67p9m0w57lspw8gsq6yphnm8623nsl8xn9j4jdzz84zm3frztj3z7s35vpzmqf6ksu8r89qk5z2zxfmu5gv8th8wclt0h4p',
|
||||
)
|
||||
|
||||
expect(is).toBeTrue()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNcryptsec with invalid ncrytpsec', () => {
|
||||
const is = NostrTypeGuard.isNcryptsec(
|
||||
'ncryptsec1qgg9947rlpvqu76pj5ecreduf9jxhselq2nae2kghhvd5g7dgjtcxfqtd67p9m0w57lspw8gsq6yphnm8623nsã8xn9j4jdzz84zm3frztj3z7s35vpzmqf6ksu8r89qk5z2zxfmu5gv8th8wclt0h4p',
|
||||
)
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
||||
test('NostrTypeGuard isNcryptsec with invalid ncrytpsec', () => {
|
||||
const is = NostrTypeGuard.isNcryptsec('note1gmtnz6q2m55epmlpe3semjdcq987av3jvx4emmjsa8g3s9x7tg4sçlreky')
|
||||
|
||||
expect(is).toBeFalse()
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue