Skip to content

Commit

Permalink
migrate increasePostVisibility into redux-style action (mattermost#1958)
Browse files Browse the repository at this point in the history
  • Loading branch information
saturninoabril authored and JayaKrishnaNamburu committed Dec 3, 2018
1 parent 98787be commit 2f59ffc
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions actions/post_utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ describe('actions/post_utils', () => {
posts: {
editingPost: {},
},
channel: {
loadingPosts: {},
postVisibility: {current_channel_id: 60},
},
},
};

Expand Down Expand Up @@ -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'}]);
});
});

0 comments on commit 2f59ffc

Please sign in to comment.