All files / test utils.ts

68% Statements 17/25
25% Branches 2/8
100% Functions 6/6
68% Lines 17/25

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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5121x 21x   21x 29x       29x     21x 54x       54x 54x                 21x 181x       29x   29x                   21x 31x     21x 1x    
import { Strings, Types } from 'cafe-utility'
import { Bee, BeeDev } from '../src'
 
export function makeBee() {
  Iif (currentBeeMode() === 'dev') {
    return new BeeDev('http://localhost:1633')
  }
 
  return new Bee(selectBeeUrl())
}
 
export function batch() {
  Iif (currentBeeMode() === 'light') {
    return Types.asString(process.env.JEST_LIGHT_BATCH_ID)
  }
 
  if (currentBeeMode() === 'full') {
    return Types.asString(process.env.JEST_FULL_BATCH_ID)
  }
 
  Iif (currentBeeMode() === 'dev') {
    return '29c91093cbbdaa1a126d2a24c3ee2c70e7c36c7653ba156829a06d07a9ccc4a4'
  }
  throw Error('Batch ID not available in ultra-light mode')
}
 
export function currentBeeMode(): 'full' | 'light' | 'ultra-light' | 'dev' {
  return 'full'
}
 
function selectBeeUrl() {
  switch (currentBeeMode()) {
    case 'full':
      return Types.asString(process.env.JEST_BEE_FULL_URL)
    case 'light':
      return Types.asString(process.env.JEST_BEE_LIGHT_URL)
    case 'ultra-light':
      return Types.asString(process.env.JEST_BEE_ULTRA_LIGHT_URL)
    default:
      throw Error('Invalid mode')
  }
}
 
export function arbitraryReference() {
  return Strings.randomHex(64)
}
 
export function arbitraryPrivateKey() {
  return Strings.randomHex(64)
}