1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-25 03:20:12 +01:00

Fix connection test

This commit fixes the "Payload thrown at incorrect API_PATH"
test, it uses the proper way to check async error throws,
taken from ava.js docs. Done with the aim to increase the
coverage and to ensure working tests. Added "transform-runtime"
to .babelrc to enable "await/async" syntax".

Part of https://github.com/bigchaindb/js-bigchaindb-driver/issues/220
This commit is contained in:
Arjun Nemani 2018-07-19 11:38:34 +05:30
parent 64713d3742
commit 48f7584374
3 changed files with 6 additions and 7 deletions

View File

@ -5,7 +5,8 @@
"plugins": [
"transform-export-extensions",
"transform-object-assign",
"transform-object-rest-spread"
"transform-object-rest-spread",
["transform-runtime", { "polyfill": false, "regenerator": true }]
],
"sourceMaps": true
}

View File

@ -46,7 +46,7 @@
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015-no-commonjs": "0.0.2",
"babel-runtime": "^6.26.0",

View File

@ -7,7 +7,7 @@ import { API_PATH } from '../constants'
const conn = new Connection(API_PATH)
test('Payload thrown at incorrect API_PATH', t => {
test('Payload thrown at incorrect API_PATH', async t => {
const path = 'http://localhost:9984/api/wrong/'
const connection = new Connection(path)
const target = {
@ -15,10 +15,8 @@ test('Payload thrown at incorrect API_PATH', t => {
status: '404 NOT FOUND',
requestURI: 'http://localhost:9984/api/wrong/transactions/transactionId'
}
connection.getTransaction('transactionId')
.catch(error => {
t.deepEqual(target, error)
})
const error = await t.throws(connection.getTransaction('transactionId'))
t.deepEqual(target, error)
})
test('Generate API URLS', t => {