Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(bridge-ui): add test case for extractIPFSCidFromUrl #16453

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/bridge-ui/src/libs/util/extractIPFSCidFromUrl.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { extractIPFSCidFromUrl } from './extractIPFSCidFromUrl';

describe('extractIPFSCidFromUrl', () => {
test('should return the correct CID when a valid IPFS URL is provided', () => {
const url = 'https://ipfs.io/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme';
const result = extractIPFSCidFromUrl(url);
expect(result).toEqual({ cid: 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG' });
});

test('should return null when an invalid IPFS URL is provided', () => {
const url = 'https://invalid-url.com';
const result = extractIPFSCidFromUrl(url);
expect(result).toEqual({ cid: null });
});
});
Loading