-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
including nostr specialized types (#409)
* including nostr types * including tests for nostr type guard * fix tests for nostr type guard * fix linter and add eslint and prettier to devcontainer * including null in nostr type guard signature * fix type, ops * including ncryptsec in nostr type guard * fix linter for ncryptsec * including ncryptsec return type for nip49 * fixing names of nostr types and types guards * fixing names of nostr types and types guards in unit tests descriptions * fix prettier * including type guard for nip5
- Loading branch information
1 parent
2143304
commit ee76d69
Showing
7 changed files
with
204 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { test, expect } from 'bun:test' | ||
import fetch from 'node-fetch' | ||
|
||
import { useFetchImplementation, queryProfile } from './nip05.ts' | ||
import { useFetchImplementation, queryProfile, NIP05_REGEX, isNip05 } from './nip05.ts' | ||
|
||
test('fetch nip05 profiles', async () => { | ||
useFetchImplementation(fetch) | ||
|
@@ -18,3 +18,15 @@ test('fetch nip05 profiles', async () => { | |
expect(p3!.pubkey).toEqual('3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d') | ||
expect(p3!.relays).toEqual(['wss://pyramid.fiatjaf.com', 'wss://nos.lol']) | ||
}) | ||
|
||
test('validate NIP05_REGEX', () => { | ||
expect(NIP05_REGEX.test('[email protected]')).toBeTrue() | ||
expect(NIP05_REGEX.test('[email protected]')).toBeTrue() | ||
expect(NIP05_REGEX.test('b&[email protected]')).toBeFalse() | ||
|
||
expect('b&[email protected]'.match(NIP05_REGEX)).toBeNull() | ||
expect(Array.from('[email protected]'.match(NIP05_REGEX) || [])).toEqual(['[email protected]', 'bob', 'bob.com.br', '.br']) | ||
|
||
expect(isNip05('[email protected]')).toBeTrue() | ||
expect(isNip05('b&[email protected]')).toBeFalse() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters