All files / test/dummy connector-listener-instances.ts

68.18% Statements 15/22
50% Branches 1/2
60% Functions 9/15
68.18% Lines 15/22

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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70      3x   5x     5x                   6x               3x         11x     6x     1x     6x             3x   6x     6x   6x                   6x   6x      
let consumer
 
// Build a dummy asset connector
export const assetConnector = {
  getAssetLocation: () => {
    return Promise.resolve('/assets/dummy/file.jpg')
  },
  getConfig: () => {
    return {}
  },
  // tslint:disable-next-line: object-literal-sort-keys
  delete: () => {
    return Promise.resolve()
  },
  download: () => {
    return Promise.resolve()
  },
  start: () => {
    return Promise.resolve(assetConnector)
  },
  unpublish: () => {
    return Promise.resolve()
  },
}
 
// Build a dummy content connector
export const contentConnector = {
  delete: () => {
    return Promise.resolve()
  },
  publish: () => {
    return Promise.resolve()
  },
  start: () => {
    return Promise.resolve(contentConnector)
  },
  unpublish: () => {
    return Promise.resolve()
  },
  updateContentType: () => {
    return Promise.resolve()
  }
}
 
let lConfig
 
// Dummy listener instance
export const listener = {
  register: (fn) => {
    Iif (typeof fn !== 'function') {
      throw new Error(`${fn} should be a function!`)
    }
    consumer = fn
 
    return
  },
  getConfig: () => {
    return lConfig
  },
  setConfig: (config) => {
    lConfig = config
  },
  start: () => {
    // simply fire events every 10 seconds
    setInterval(consumer, 10 * 1000)
 
    return Promise.resolve()
  },
}