Skip to content

Commit

Permalink
test(bridge-ui): add test case for extractIPFSCidFromUrl (#16453)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillXing committed Mar 16, 2024
1 parent ee1233d commit 0f27341
Showing 1 changed file with 15 additions and 0 deletions.
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 });
});
});

0 comments on commit 0f27341

Please sign in to comment.