Skip to content

Commit

Permalink
Added tests for block height actions (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuggins authored and dvdschwrtz committed Feb 13, 2018
1 parent 54280eb commit 61079ea
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions __tests__/actions/blockHeightActions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import blockHeightActions from '../../app/actions/blockHeightActions'
import { TEST_NETWORK_ID } from '../../app/core/constants'

describe('blockHeightActions', () => {
describe('request', () => {
test('returns an action object', () => {
expect(blockHeightActions.request({ networkId: TEST_NETWORK_ID })).toEqual({
batch: false,
type: 'BLOCK_HEIGHT/REQ/REQUEST',
meta: {
id: 'BLOCK_HEIGHT',
type: 'REQ/REQUEST'
},
payload: {
fn: expect.any(Function)
}
})
})

test("payload function requests the network's block height", async (done) => {
const request = blockHeightActions.request({ networkId: TEST_NETWORK_ID })
expect(await request.payload.fn({})).toEqual(586435)
done()
})
})

describe('retry', () => {
test('returns an action object', () => {
expect(blockHeightActions.retry({ networkId: TEST_NETWORK_ID })).toEqual({
batch: false,
type: 'BLOCK_HEIGHT/REQ/RETRY',
meta: {
id: 'BLOCK_HEIGHT',
type: 'REQ/RETRY'
},
payload: {
fn: expect.any(Function)
}
})
})

test("payload function retries request for the network's block height", async (done) => {
const request = blockHeightActions.retry({ networkId: TEST_NETWORK_ID })
expect(await request.payload.fn({})).toEqual(586435)
done()
})
})

describe('cancel', () => {
test('returns an action object', () => {
expect(blockHeightActions.cancel()).toEqual({
batch: false,
type: 'BLOCK_HEIGHT/REQ/CANCEL',
meta: {
id: 'BLOCK_HEIGHT',
type: 'REQ/CANCEL'
}
})
})
})

describe('reset', () => {
test('returns an action object', () => {
expect(blockHeightActions.reset()).toEqual({
batch: false,
type: 'BLOCK_HEIGHT/REQ/RESET',
meta: {
id: 'BLOCK_HEIGHT',
type: 'REQ/RESET'
}
})
})
})
})

0 comments on commit 61079ea

Please sign in to comment.