-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for block height actions (#678)
- Loading branch information
1 parent
54280eb
commit 61079ea
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
}) | ||
}) | ||
}) | ||
}) |