From 2f59ffc94929e4f641f99b71d3b2c6e740f6173b Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Wed, 31 Oct 2018 00:15:23 +0800 Subject: [PATCH] migrate increasePostVisibility into redux-style action (#1958) --- actions/post_utils.test.js | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/actions/post_utils.test.js b/actions/post_utils.test.js index 1a9e5dd3486c..f03afb276484 100644 --- a/actions/post_utils.test.js +++ b/actions/post_utils.test.js @@ -93,6 +93,10 @@ describe('actions/post_utils', () => { posts: { editingPost: {}, }, + channel: { + loadingPosts: {}, + postVisibility: {current_channel_id: 60}, + }, }, }; @@ -132,4 +136,48 @@ describe('actions/post_utils', () => { await testStore.dispatch(PostActionsUtils.setChannelReadAndView(newPost, websocketProps)); expect(testStore.getActions()).toEqual([MARK_CHANNEL_AS_READ, MARK_CHANNEL_AS_VIEWED]); }); + + test('increasePostVisibility', async () => { + const testStore = await mockStore(initialState); + + await testStore.dispatch(Actions.increasePostVisibility('current_channel_id')); + expect(testStore.getActions()).toEqual([ + { + meta: {batch: true}, + payload: [ + {channelId: 'current_channel_id', data: true, type: 'LOADING_POSTS'}, + {amount: 30, data: 'current_channel_id', type: 'INCREASE_POST_VISIBILITY'}, + ], + type: 'BATCHING_REDUCER.BATCH', + }, + {args: ['current_channel_id', 2, 30], type: 'MOCK_GET_POSTS'}, + {channelId: 'current_channel_id', data: false, type: 'LOADING_POSTS'}, + ]); + + await testStore.dispatch(Actions.increasePostVisibility('current_channel_id', 'latest_post_id')); + expect(testStore.getActions()).toEqual([ + { + meta: {batch: true}, + payload: [ + {channelId: 'current_channel_id', data: true, type: 'LOADING_POSTS'}, + {amount: 30, data: 'current_channel_id', type: 'INCREASE_POST_VISIBILITY'}, + ], + type: 'BATCHING_REDUCER.BATCH', + }, + {args: ['current_channel_id', 2, 30], type: 'MOCK_GET_POSTS'}, + {channelId: 'current_channel_id', data: false, type: 'LOADING_POSTS'}, + { + meta: {batch: true}, + payload: [ + {channelId: 'current_channel_id', data: true, type: 'LOADING_POSTS'}, + {amount: 30, data: 'current_channel_id', type: 'INCREASE_POST_VISIBILITY'}, + ], + type: 'BATCHING_REDUCER.BATCH', + }, + { + args: ['current_channel_id', 'latest_post_id', 2, 30], + type: 'MOCK_GET_POSTS_BEFORE', + }, + {channelId: 'current_channel_id', data: false, type: 'LOADING_POSTS'}]); + }); });