18 lines
659 B
TypeScript
18 lines
659 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { nip19 } from 'nostr-tools';
|
|
import { parseOperatorPubkey } from './coordinator';
|
|
|
|
const PUBKEY = 'a'.repeat(64);
|
|
|
|
describe('parseOperatorPubkey', () => {
|
|
it('accepts npub and raw hex', () => {
|
|
expect(parseOperatorPubkey(nip19.npubEncode(PUBKEY))).toBe(PUBKEY);
|
|
expect(parseOperatorPubkey(PUBKEY)).toBe(PUBKEY);
|
|
});
|
|
|
|
it('rejects empty, malformed and coordinator URLs', () => {
|
|
expect(parseOperatorPubkey('')).toBeNull();
|
|
expect(parseOperatorPubkey('not-a-key')).toBeNull();
|
|
expect(parseOperatorPubkey('https://cordn.net/chat/coordinators?c=nprofile1bad')).toBeNull();
|
|
});
|
|
});
|