From 61079ea78e7e3fa9e2a244d8e21b3bfd6a62d10d Mon Sep 17 00:00:00 2001 From: Matt Huggins Date: Mon, 12 Feb 2018 18:58:34 -0600 Subject: [PATCH] Added tests for block height actions (#678) --- __tests__/actions/blockHeightActions.test.js | 74 ++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 __tests__/actions/blockHeightActions.test.js diff --git a/__tests__/actions/blockHeightActions.test.js b/__tests__/actions/blockHeightActions.test.js new file mode 100644 index 000000000..aee449e27 --- /dev/null +++ b/__tests__/actions/blockHeightActions.test.js @@ -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' + } + }) + }) + }) +})