From 628d73eb810711638667fa386ab37d9c1d3f3022 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 9 Jun 2020 17:22:35 -0500 Subject: [PATCH] Tests: actions/about.js --- app/soapbox/actions/__tests__/about-test.js | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/soapbox/actions/__tests__/about-test.js b/app/soapbox/actions/__tests__/about-test.js index c0caf5e2c..941e402eb 100644 --- a/app/soapbox/actions/__tests__/about-test.js +++ b/app/soapbox/actions/__tests__/about-test.js @@ -3,6 +3,7 @@ import thunk from 'redux-thunk'; import { FETCH_ABOUT_PAGE_REQUEST, FETCH_ABOUT_PAGE_SUCCESS, + FETCH_ABOUT_PAGE_FAIL, fetchAboutPage, } from '../about'; import { Map as ImmutableMap } from 'immutable'; @@ -12,11 +13,12 @@ const middlewares = [thunk]; const mockStore = configureMockStore(middlewares); describe('fetchAboutPage()', () => { - beforeEach(() => stubApi(mock => { - mock.onGet('/instance/about/index.html').reply(200, '

Hello world

'); - })); + it('creates the expected actions on success', () => { + + stubApi(mock => { + mock.onGet('/instance/about/index.html').reply(200, '

Hello world

'); + }); - it('creates the expected actions', () => { const expectedActions = [ { type: FETCH_ABOUT_PAGE_REQUEST, slug: 'index' }, { type: FETCH_ABOUT_PAGE_SUCCESS, slug: 'index' }, @@ -27,4 +29,16 @@ describe('fetchAboutPage()', () => { expect(store.getActions()).toEqual(expectedActions); }); }); + + it('creates the expected actions on failure', () => { + const expectedActions = [ + { type: FETCH_ABOUT_PAGE_REQUEST, slug: 'asdf' }, + { type: FETCH_ABOUT_PAGE_FAIL, slug: 'asdf' }, + ]; + const store = mockStore(ImmutableMap()); + + return store.dispatch(fetchAboutPage('asdf')).then(() => { + expect(store.getActions()).toEqual(expectedActions); + }); + }); });