mattermost-mobile/app/store/middleware.test.js
Jesse Hallam 210b3512b1 MM-10460: avoid double post on restore (#1667)
* add test to messageRetention to verify outgoing action type

* ensure messageRetention passes the original action type through

* fix linting issues
2018-05-15 11:39:35 -04:00

73 lines
2 KiB
JavaScript

// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
/* eslint-disable max-nested-callbacks */
import assert from 'assert';
import {ViewTypes} from 'app/constants';
import {messageRetention} from 'app/store/middleware';
jest.mock('react-native-fetch-blob', () => {
return {
DocumentDir: () => null,
polyfill: () => null,
fs: {
dirs: {
},
},
};
});
jest.mock('react-native-device-info', () => {
return {
getVersion: () => '0.0.0',
getBuildNumber: () => '0',
};
});
describe('store/middleware', () => {
describe('messageRetention', () => {
describe('should chain the same incoming action type', () => {
const actions = [
{
type: 'persist/REHYDRATE',
payload: {
views: {
team: {
},
},
},
},
{
type: ViewTypes.DATA_CLEANUP,
payload: {
entities: {
channels: {
},
posts: {
},
},
views: {
team: {
},
},
},
},
{
type: 'other',
},
];
actions.forEach((action) => {
it(`for action type ${action.type}`, () => {
const store = {};
const next = (a) => a;
const nextAction = messageRetention(store)(next)(action);
assert.equal(action.type, nextAction.type);
});
});
});
});
});