From d7dc0df3fd320d95f081dbbd3005fe61d841154d Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 16 Aug 2017 00:11:15 -0500 Subject: [PATCH] feature(tests): add basic API tests --- README.md | 1 - test/api/index.spec.js | 55 +++++++++++++++++++ .../reducers/__snapshots__/peers.spec.js.snap | 15 +++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 test/api/index.spec.js diff --git a/README.md b/README.md index 69d9bfe8..0925ad79 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,6 @@ Join us on [slack](https://join.slack.com/t/zaphq/shared_invite/MjI2MTY4NTcwMDUy - [ ] Component tests - [ ] Container tests - [ ] API call tests -- [ ] ## Q & A (Quality and Assurance) diff --git a/test/api/index.spec.js b/test/api/index.spec.js new file mode 100644 index 00000000..9231f2bc --- /dev/null +++ b/test/api/index.spec.js @@ -0,0 +1,55 @@ +import { callApi } from '../../app/api' + +describe('API', () => { + describe('getinfo', () => { + it('is synced to the chain', async () => { + const info = await callApi('info') + expect(info.data.synced_to_chain).toEqual(true) + }) + + it('only supports 1 chain at a time', async () => { + const info = await callApi('info') + expect(info.data.chains.length).toEqual(1) + }) + }) + + describe('balance', () => { + it('returns wallet balance', async () => { + const wallet_balances = await callApi('wallet_balance') + expect(typeof(wallet_balances.data.balance)).toEqual('string') + }) + + it('returns channel balance', async () => { + const channel_balances = await callApi('channel_balance') + expect(typeof(channel_balances.data.balance)).toEqual('string') + }) + }) + + describe('peers', () => { + it('peers is an array', async () => { + const peers = await callApi('peers') + expect(Array.isArray(peers.data.peers)).toEqual(true) + }) + }) + + describe('channels', () => { + it('channels is an array', async () => { + const channels = await callApi('channels') + expect(Array.isArray(channels.data.channels)).toEqual(true) + }) + }) + + describe('invoices', () => { + it('invoices is an array', async () => { + const invoices = await callApi('invoices') + expect(Array.isArray(invoices.data.invoices)).toEqual(true) + }) + }) + + describe('payments', () => { + it('payments is an array', async () => { + const payments = await callApi('payments') + expect(Array.isArray(payments.data.payments)).toEqual(true) + }) + }) +}) diff --git a/test/reducers/__snapshots__/peers.spec.js.snap b/test/reducers/__snapshots__/peers.spec.js.snap index b2bea94c..47c7cc99 100644 --- a/test/reducers/__snapshots__/peers.spec.js.snap +++ b/test/reducers/__snapshots__/peers.spec.js.snap @@ -122,6 +122,21 @@ Object { } `; +exports[`reducers peersReducer should correctly receivePeers 1`] = ` +Object { + "connecting": false, + "disconnecting": false, + "peer": null, + "peerForm": Object { + "host": "", + "isOpen": false, + "pubkey": "", + }, + "peers": "foo", + "peersLoading": false, +} +`; + exports[`reducers peersReducer should correctly setPeer 1`] = ` Object { "connecting": false,