Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed May 15, 2024
1 parent bf7ef9c commit f2f9505
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/snaps-utils/src/ui.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,19 @@ describe('getJsxElementFromComponent', () => {
});

describe('validateTextLinks', () => {
it('handles custom protocols', () => {
const allowedProtocols = ['http:', 'file:'];
expect(() =>
validateTextLinks('[test](http://foo.bar)', () => false, allowedProtocols),

Check failure on line 537 in packages/snaps-utils/src/ui.test.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (@metamask/snaps-utils)

Replace `'[test](http://foo.bar)',·()·=>·false,·allowedProtocols` with `⏎········'[test](http://foo.bar)',⏎········()·=>·false,⏎········allowedProtocols,⏎······`
).not.toThrow();
expect(() =>
validateTextLinks('[test](https://foo.bar)', () => false, allowedProtocols),

Check failure on line 540 in packages/snaps-utils/src/ui.test.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (@metamask/snaps-utils)

Replace `'[test](https://foo.bar)',·()·=>·false,·allowedProtocols` with `⏎········'[test](https://foo.bar)',⏎········()·=>·false,⏎········allowedProtocols,⏎······`
).toThrow();

Check failure on line 541 in packages/snaps-utils/src/ui.test.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (@metamask/snaps-utils)

Add an error message to toThrow()
expect(() =>
validateTextLinks('<file:///var/www/index.html>', () => false, allowedProtocols),

Check failure on line 543 in packages/snaps-utils/src/ui.test.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (@metamask/snaps-utils)

Replace `'<file:///var/www/index.html>',·()·=>·false,·allowedProtocols` with `⏎········'<file:///var/www/index.html>',⏎········()·=>·false,⏎········allowedProtocols,⏎······`
).not.toThrow();
});

it('passes for valid links', () => {
expect(() =>
validateTextLinks('[test](https://foo.bar)', () => false),
Expand Down

0 comments on commit f2f9505

Please sign in to comment.