import { describe, it, expect } from 'vitest' import { normalizeRelayUrl } from '@welshman/util' describe('Guarded normalizeRelayUrl', () => { it('guarded with undefined should not crash, result is undefined', () => { const undefinedInput: string | undefined = undefined const guarded = undefinedInput ? normalizeRelayUrl(undefinedInput) : undefined expect(guarded).toBeUndefined() }) it('guarded with empty string should not crash, result is undefined', () => { const emptyInput = '' const guarded = emptyInput ? normalizeRelayUrl(emptyInput) : undefined expect(guarded).toBeUndefined() }) it('guarded with valid relay still normalizes correctly', () => { const validInput = 'wss://relay.damus.io' const guarded = validInput ? normalizeRelayUrl(validInput) : undefined expect(guarded).toBe('wss://relay.damus.io/') }) })