Skip to content

Commit 0d3f891

Browse files
committed
add test
1 parent bf7ef9c commit 0d3f891

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/snaps-utils/src/ui.test.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,31 @@ describe('getJsxElementFromComponent', () => {
531531
});
532532

533533
describe('validateTextLinks', () => {
534+
it('handles custom protocols', () => {
535+
const allowedProtocols = ['http:', 'file:'];
536+
expect(() =>
537+
validateTextLinks(
538+
'[test](http://foo.bar)',
539+
() => false,
540+
allowedProtocols,
541+
),
542+
).not.toThrow();
543+
expect(() =>
544+
validateTextLinks(
545+
'[test](https://foo.bar)',
546+
() => false,
547+
allowedProtocols,
548+
),
549+
).toThrow('Invalid URL: Protocol must be one of: http:, file:.');
550+
expect(() =>
551+
validateTextLinks(
552+
'<file:///var/www/index.html>',
553+
() => false,
554+
allowedProtocols,
555+
),
556+
).not.toThrow();
557+
});
558+
534559
it('passes for valid links', () => {
535560
expect(() =>
536561
validateTextLinks('[test](https://foo.bar)', () => false),

0 commit comments

Comments
 (0)