All files / src/domain/chains/useCases isMockChain.ts

100% Statements 6/6
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5

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          170x 978x     1x     169x     2x    
import { BLOCKCHAINS } from '@blockcerts/explorer-lookup';
import type { IBlockchainObject } from '@blockcerts/explorer-lookup';
 
export default function isMockChain (chain: IBlockchainObject): boolean {
  if (chain) {
    const chainCode = typeof chain === 'string' ? chain : chain.code; // TODO: can it be string?
    const isChainValid = Object.keys(BLOCKCHAINS).some(chainObj => chainObj === chainCode);
 
    if (!isChainValid) {
      return false;
    }
 
    return !!BLOCKCHAINS[chainCode].test;
  }
 
  return false;
}