1import { expect } from 'chai';2import { getApiConnection } from '../substrate/substrate-api';3import { getOwnedNfts } from './util/fetch';4import { mintNft, createCollection } from './util/tx';56describe("integration test: get owned NFTs", () => {7 let api: any;8 before(async () => { api = await getApiConnection(); });910 const alice = '//Alice';1112 it("fetch all NFTs owned by a user", async () => {13 const owner = alice;14 const collectionMetadata = 'aliceCollectionMetadata';15 const collectionMax = null;16 const collectionSymbol = 'AliceSym';17 const recipientUri = null;18 const royalty = null;19 const nftMetadata = 'alice-NFT-metadata';2021 let collectionId = await createCollection(22 api,23 alice,24 collectionMetadata,25 collectionMax,26 collectionSymbol27 );2829 const nftIds = [30 await mintNft(31 api,32 alice,33 owner,34 collectionId,35 nftMetadata + '-0',36 recipientUri,37 royalty38 ),39 await mintNft(40 api,41 alice,42 owner,43 collectionId,44 nftMetadata + '-1',45 recipientUri,46 royalty47 ),48 await mintNft(49 api,50 alice,51 owner,52 collectionId,53 nftMetadata + '-2',54 recipientUri,55 royalty56 )57 ];5859 const ownedNfts = await getOwnedNfts(api, alice, collectionId);6061 const isFound = (nftId: number) => {62 return ownedNfts.find((ownedNftId) => {63 return ownedNftId === nftId64 }) !== undefined;65 };6667 nftIds.forEach((nftId) => {68 expect(isFound(nftId), `NFT ${nftId} should be owned by ${alice}`)69 .to.be.true70 });71 });7273 after(() => { api.disconnect(); });74});