25 lines
717 B
TypeScript
25 lines
717 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);
|
|
});
|
|
});
|