Browse Source

feature(tests): add basic API tests

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
d7dc0df3fd
  1. 1
      README.md
  2. 55
      test/api/index.spec.js
  3. 15
      test/reducers/__snapshots__/peers.spec.js.snap

1
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)

55
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)
})
})
})

15
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,

Loading…
Cancel
Save