{"size": 1276, "ext": "js", "max_stars_repo_path": "tests/index.js", "max_stars_repo_name": "ln-markets/bitcoind-rpc", "max_stars_repo_stars_event_min_datetime": "2022-03-06T10:07:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-06T10:14:12.000Z", "max_issues_repo_path": "tests/index.js", "max_issues_repo_name": "ln-markets/bitcoind-rpc", "max_issues_repo_issues_event_min_datetime": "2021-12-22T11:20:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-22T11:20:18.000Z", "max_forks_repo_path": "tests/index.js", "max_forks_repo_name": "ln-markets/bitcoind-rpc", "max_forks_repo_forks_event_min_datetime": "2022-03-06T10:08:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-06T10:08:05.000Z"}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 22.7857142857, "max_line_length": 67, "alphanum_fraction": 0.6222570533}
import test from 'ava'
import BitcoindRpcClient from '../src/index.js'

test('New instance', (t) => {
  const instance = new BitcoindRpcClient()
  t.is(instance.constructor.name, 'BitcoindRpcClient')
})

test('Method is not a string - Number', (t) => {
  const bitcoind = new BitcoindRpcClient()
  const error = t.throws(
    () => {
      bitcoind.request(1337)
    },
    { instanceOf: TypeError }
  )

  t.is(error.message, 'Method should be a string')
})

test('Method is not a string - Object', (t) => {
  const bitcoind = new BitcoindRpcClient()
  const error = t.throws(
    () => {
      bitcoind.request({ satoshi: true })
    },
    { instanceOf: TypeError }
  )

  t.is(error.message, 'Method should be a string')
})

test('Method is an empty string', (t) => {
  const bitcoind = new BitcoindRpcClient()
  const error = t.throws(
    () => {
      bitcoind.request('')
    },
    { instanceOf: Error }
  )

  t.is(error.message, 'Method should not be empty')
})

test('Parameters is not an object or array', (t) => {
  const bitcoind = new BitcoindRpcClient()
  const error = t.throws(
    () => {
      bitcoind.request('getblockcount', 'parameters')
    },
    { instanceOf: TypeError }
  )

  t.is(error.message, 'Parameters should be an object or an array')
})
