Skip to content

Commit 778b8fa

Browse files
committed
add additional test case
1 parent 9bfe83c commit 778b8fa

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ describe("Tests the ipfs-race library.", () => {
1111
const testCidWithPathResult = {"image":"ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ","attributes":[{"trait_type":"Earring","value":"Silver Hoop"},{"trait_type":"Background","value":"Orange"},{"trait_type":"Fur","value":"Robot"},{"trait_type":"Clothes","value":"Striped Tee"},{"trait_type":"Mouth","value":"Discomfort"},{"trait_type":"Eyes","value":"X Eyes"}]};
1212
const testUrlSubdomainWithPath = "https://bafybeih3dhxuzle4nt2rirdezbssc43vjrws2f7zocbzrsgjqe5zo3b23e.ipfs.nftstorage.link/10896.json";
1313
const testUrlSubdomainWithResult = {"name":"Iron Pigeon #10896 1st Edition","symbol":"XPTCS","description":"Mike Tyson brings his love for pigeons to the Metaverse by making them the second set in the Ex Populus Trading Card System. Mint your own Iron Pigeon and evolve your way to Legendary in the game Final Form. Learn more about Final Form: https://expopulus.com/games/final-form","seller_fee_basis_points":1000,"image":"https://ipfs.io/ipfs/QmbrCdrecFDeuDKukaC97vb3uZ5ioHiWzzb1VncLDKhFGA","external_url":"https://ironpigeons.expopulus.com","attributes":[{"trait_type":"Rarity","value":"rare"},{"trait_type":"Power","value":"286"},{"trait_type":"Health","value":"healthy"},{"trait_type":"Attack","value":"formidable"},{"trait_type":"Ability 1","value":"Evade"},{"trait_type":"House","value":"Machines"},{"trait_type":"Set Name","value":"Iron Pigeons"},{"trait_type":"Set Number","value":"2"},{"trait_type":"Edition","value":"1st Edition"},{"trait_type":"Card Number","value":"10896"},{"trait_type":"Body","value":"shredded white"},{"trait_type":"Costume","value":"high-top fade"},{"trait_type":"Beak","value":"standard"},{"trait_type":"Eyes","value":"pink"},{"trait_type":"Background","value":"blue"}],"collection":{"name":"Iron Pigeons","family":"Ex Populus Trading Card System"},"properties":{"creators":[{"address":"3NXTh2Bw64a72RGGJ2mh8V7YEW2jERGdESjqxyvBoXo1","share":35},{"address":"39gMkx283UsuKNt5ogETWdHHaGyBwbh8sU5cKAEQjU2w","share":15},{"address":"4MnG71K4EXDHFysnnftV9YLDhnUjfxY5jTE34QAx4Pho","share":50}],"files":[{"uri":"https://ipfs.io/ipfs/QmbrCdrecFDeuDKukaC97vb3uZ5ioHiWzzb1VncLDKhFGA","type":"image/png"},{"uri":"https://ipfs.io/ipfs/QmXT3yXQ6dEZawcGTwXjwQhTaDgKMwuTts6fU9S2jyyPoh","type":"image/png"},{"uri":"https://ipfs.io/ipfs/QmUCSep13eQCrNpAnQSwpadtJDgUW4D1CWUUooFYeUMUGt","type":"image/png"},{"uri":"https://ipfs.io/ipfs/QmY9KQYHTMxGHK7VizvmyqDFxR5LgRfEGjkJmuuax7nvVL","type":"image/png"}],"category":"image"}};
14-
14+
const testUrlWith2SubdomainsWhere1IsIpfs = "https://bafybeicqjhjcar5x7jvtz62zc4hbakczvktbu3zvbn3o3wnmqpbxgbdkli.ipfs.nftstorage.link/0.json";
15+
const testUrlWith2SubdomainsWhere1IsIpfsResult = {"name":"Ryder One","symbol":"RO","description":"Wall Street Degens Bid Goodbye Seed phrases” is a special Ryder NFT for Magic Eden created by Quentin Saubadu.","seller_fee_basis_points":500,"image":"https://bafybeihphsiusu2iyw42qjfm7yngieayscfbxmzmjm4zovzt6lxszjelia.ipfs.nftstorage.link/0.png?ext=png","attributes":[],"collection":{"name":"Ryder One","family":"Ryder One"},"properties":{"creators":[{"address":"CxsRPwBU4HdpzEPGVAvX1vxnfSZFDBcMmv8TqBww7Mpw","share":100}],"category":"image","files":[{"uri":"https://bafybeihphsiusu2iyw42qjfm7yngieayscfbxmzmjm4zovzt6lxszjelia.ipfs.nftstorage.link/0.png?ext=png","type":"image/png"}]}};
1516

1617
it("cid with no path", async () => {
1718
const {response, urlResolvedFrom} = await resolve(testCidWithNoPath);
@@ -48,6 +49,11 @@ describe("Tests the ipfs-race library.", () => {
4849
expect(await response.json(), urlResolvedFrom).to.deep.equal(testUrlSubdomainWithResult);
4950
});
5051

52+
it("test ipfs subdomain with 2 subdomains where 1 is ipfs", async () => {
53+
const {response, urlResolvedFrom} = await resolve(testUrlWith2SubdomainsWhere1IsIpfs);
54+
expect(await response.json(), urlResolvedFrom).to.deep.equal(testUrlWith2SubdomainsWhere1IsIpfsResult);
55+
});
56+
5157
it("check that each default ipfs gateway to be a valid url", () => {
5258
for (const url of defaultIpfsGateways) {
5359
expect(isValidHttpUrl(url)).to.be.true;

0 commit comments

Comments
 (0)