text: const { assert } = require('chai')
  const { assertSuccess, assertError } = require('@chainlink/external-adapter')
  const { execute } = require('../adapter')
  
  describe('execute', () => {
    const jobID = '1'
  
    context('successful calls @integration', () => {
      const requests = [
        {
          name: 'id not supplied',
          testData: { data: { blockchain: 'BTC' } },
        },
        {
          name: 'blockchain',
          testData: { id: jobID, data: { blockchain: 'BTC' } },
        },
        {
          name: 'coin',
          testData: { id: jobID, data: { coin: 'BTC' } },
        },
      ]
  
      requests.forEach((req) => {
        it(`${req.name}`, (done) => {
          execute(req.testData, (statusCode, data) => {
            assertSuccess({ expected: 200, actual: statusCode }, data, jobID)
            assert.isAbove(data.result, 0)
            assert.isAbove(data.data.result, 0)
            done()
          })
        })
      })
    })
  
    context('validation error', () => {
      const requests = [
        { name: 'empty body', testData: {} },
        { name: 'empty data', testData: { data: {} } },
      ]
  
      requests.forEach((req) => {
        it(`${req.name}`, (done) => {
          execute(req.testData, (statusCode, data) => {
            assertError({ expected: 400, actual: statusCode }, data, jobID)
            done()
          })
        })
      })
    })
  
    context('error calls @integration', () => {
      const requests = [
        {
          name: 'unknown blockchain',
          testData: { id: jobID, data: { blockchain: 'not_real' } },
        },
      ]
  
      requests.forEach((req) => {
        it(`${req.name}`, (done) => {
          execute(req.testData, (statusCode, data) => {
            assertError({ expected: 500, actual: statusCode }, data, jobID)
            done()
          })
        })
      })
    })
  })
  