mattermost-mobile/app/screens/post_options/index.test.js
Matheus Cardoso 3bd3e56025
MM-17838 Wrap reactions when they exceed screen size (#3144)
* MM-17838 Wrap reactions when they exceed screen size

* Hide add reaction button after 40 reactions

* Hide add reaction button after 40 reactions

* Fix tests

* Fix crash when post has no reactions and convert to factory

* Create constant and use a separate prop for allowing more reactions
2019-11-18 22:13:34 -03:00

68 lines
2.3 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {makeMapStateToProps} from './index';
import * as channelSelectors from 'mattermost-redux/selectors/entities/channels';
import * as generalSelectors from 'mattermost-redux/selectors/entities/general';
import * as userSelectors from 'mattermost-redux/selectors/entities/users';
import * as commonSelectors from 'mattermost-redux/selectors/entities/common';
import * as teamSelectors from 'mattermost-redux/selectors/entities/teams';
import * as deviceSelectors from 'app/selectors/device';
import * as preferencesSelectors from 'mattermost-redux/selectors/entities/preferences';
channelSelectors.getChannel = jest.fn();
channelSelectors.getCurrentChannelId = jest.fn();
generalSelectors.getConfig = jest.fn();
generalSelectors.getLicense = jest.fn();
generalSelectors.hasNewPermissions = jest.fn();
userSelectors.getCurrentUserId = jest.fn();
commonSelectors.getCurrentUserId = jest.fn();
commonSelectors.getCurrentChannelId = jest.fn();
teamSelectors.getCurrentTeamId = jest.fn();
teamSelectors.getCurrentTeamUrl = jest.fn();
deviceSelectors.getDimensions = jest.fn();
deviceSelectors.isLandscape = jest.fn();
preferencesSelectors.getTheme = jest.fn();
describe('makeMapStateToProps', () => {
const baseState = {
entities: {
posts: {
posts: {
post_id: {},
},
reactions: {
post_id: {},
},
},
},
};
const baseOwnProps = {
post: {
id: 'post_id',
},
};
test('canFlag is false for system messages', () => {
const ownProps = {
...baseOwnProps,
isSystemMessage: true,
};
const mapStateToProps = makeMapStateToProps();
const props = mapStateToProps(baseState, ownProps);
expect(props.canFlag).toBe(false);
});
test('canFlag is true for non-system messages', () => {
const ownProps = {
...baseOwnProps,
isSystemMessage: false,
};
const mapStateToProps = makeMapStateToProps();
const props = mapStateToProps(baseState, ownProps);
expect(props.canFlag).toBe(true);
});
});