diff --git a/lib/api-code-examples.test.js b/lib/api-code-examples.test.js index 6e4ddc4..74c08c0 100644 --- a/lib/api-code-examples.test.js +++ b/lib/api-code-examples.test.js @@ -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') @@ -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({ @@ -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 = "..."; @@ -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', @@ -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) }) diff --git a/package.json b/package.json index 20ea4d0..0d25972 100644 --- a/package.json +++ b/package.json @@ -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"