All files / src/mockProviders mockAssetProvider.ts

66.66% Statements 6/9
0% Branches 0/2
0% Functions 0/3
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 352x 2x   2x                     2x                 2x                      
import { Asset, Cardano } from '@cardano-sdk/core';
import { handleAssetId, handleAssetName, handleFingerprint, handlePolicyId } from './mockData';
 
export const asset: Asset.AssetInfo = {
  assetId: Cardano.AssetId('659f2917fb63f12b33667463ee575eeac1845bbc736b9c0bbc40ba8254534c41'),
  fingerprint: Cardano.AssetFingerprint('asset1rjklcrnsdzqp65wjgrg55sy9723kw09mlgvlc3'),
  name: Cardano.AssetName('54534c41'),
  nftMetadata: null,
  policyId: Cardano.PolicyId('7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc373'),
  quantity: 1000n,
  supply: 1000n,
  tokenMetadata: null
};
 
export const handleAssetInfo: Asset.AssetInfo = {
  assetId: handleAssetId,
  fingerprint: handleFingerprint,
  name: handleAssetName,
  policyId: handlePolicyId,
  quantity: 1n,
  supply: 1n
};
 
export const mockAssetProvider = () => ({
  getAsset: jest.fn().mockResolvedValue(asset),
  getAssets: jest
    .fn()
    .mockImplementation(async ({ assetIds }) =>
      assetIds.map((assetId: Cardano.AssetId) => (assetId === handleAssetId ? handleAssetInfo : asset))
    ),
  healthCheck: jest.fn().mockResolvedValue({ ok: true })
});
 
export type MockAssetProvider = ReturnType<typeof mockAssetProvider>;