Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
tests: add remaining api codes examples tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaineder committed Oct 14, 2019
1 parent c9eb9ae commit a500989
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
47 changes: 31 additions & 16 deletions lib/api-code-examples.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const dotenv = require('dotenv')
const test = require('ava')
const uuid = require('uuid')
const queryString = require('query-string');
const createSdkClient = require('./client')
const pkg = require('../package.json')

Expand Down Expand Up @@ -38,6 +39,7 @@ const clientId = uuid()
const exportId = uuid()
const txId = uuid()
const serial_number = clientId
const last_revision = 1;

test.before(async t => {
await client({
Expand Down Expand Up @@ -174,6 +176,19 @@ test('list all exports', async t => {
t.is(body._type, 'EXPORT_LIST')
})

test('list exports', async t => {
// const tssId = "...";
const response = await client({
url: `tss/${tssId}/export`,
method: 'GET',
})
const { body } = response

// The code example ends here.

t.is(body._type, 'EXPORT_LIST')
})

test('retrieve export', async t => {
// const tssId = "...";
// const exportId = "...";
Expand Down Expand Up @@ -288,27 +303,26 @@ test('retrieve transaction', async t => {
t.is(body._id, txId)
})

// test('retrieve transaction log', async t => {
// // const tssId = "...";
// // const txId = "...";
// const response = await client({
// url: `tss/${tssId}/tx/${txId}/log`,
// method: 'GET',
// })
test('retrieve transaction log', async t => {
// const tssId = "...";
// const txId = "...";
const response = await client({
url: `tss/${tssId}/tx/${txId}/log`,
method: 'GET',
json: false,
responseType: 'buffer'
})

// // The code example ends here.
// The code example ends here.

// t.truthy(response)
// })
t.truthy(response)
})


test('upsert transaction', async t => {
// const tssId = "...";
// const txId = "...";
// const clientId = "...";

// TODO: query string

const response = await client({
url: `tss/${tssId}/tx/${txId}`,
method: 'PUT',
Expand All @@ -321,12 +335,13 @@ test('upsert transaction', async t => {
other: {}
}
}
}
},
query: { last_revision }
})
const { body } = response

// The code example ends here.

t.is(body._type, 'CLIENT')
t.is(body._id, clientId)
t.is(body._type, 'TRANSACTION')
t.is(body._id, txId)
})
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
"ffi-napi": "^2.4.5",
"got": "^9.6.0",
"node-gyp": "^5.0.4",
"ref-napi": "^1.4.1",
"uuid": "3.3.3"
"ref-napi": "^1.4.1"
},
"devDependencies": {
"@pgaubatz/uuid": "^0.1.0",
"ava": "^2.2.0",
"dotenv": "^8.0.0",
"nyc": "^14.1.1",
"standard": "^13.0.0"
"query-string": "^6.8.3",
"standard": "^13.0.0",
"uuid": "^3.3.3"
},
"files": [
"*.js"
Expand Down

0 comments on commit a500989

Please sign in to comment.