Files
splitt-the-bill/shared/utils/paymentLink.test.ts
T
2026-07-01 15:43:18 +02:00

25 lines
704 B
TypeScript

import { describe, expect, it } from 'vitest'
import { isValidPaymentLink } from './paymentLink'
describe('isValidPaymentLink', () => {
it('accepts an https PayPal.me link', () => {
expect(isValidPaymentLink('https://paypal.me/janedoe')).toBe(true)
})
it('accepts an http link', () => {
expect(isValidPaymentLink('http://paypal.me/janedoe')).toBe(true)
})
it('rejects an empty string', () => {
expect(isValidPaymentLink('')).toBe(false)
})
it('rejects a javascript: URI', () => {
expect(isValidPaymentLink('javascript:alert(1)')).toBe(false)
})
it('rejects a value that is not a URL at all', () => {
expect(isValidPaymentLink('not a link')).toBe(false)
})
})