From 49b9cf436f4dd187cf4946bec307568439cec7a8 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Mon, 2 Aug 2021 19:17:29 -0300 Subject: [PATCH] [IMPROVE] - fixing some errors appoint by jest --- .../__snapshots__/Storyshots.test.js.snap | 22 ++++++++++--------- app/containers/Avatar/Avatar.tsx | 13 ++++++----- app/containers/Avatar/index.tsx | 5 +++++ app/containers/Button/index.tsx | 8 +++++++ .../HeaderButton/HeaderButtonContainer.tsx | 2 +- app/containers/LoginServices.tsx | 4 ++++ app/containers/MessageBox/index.tsx | 13 ++++++++++- app/containers/RoomHeader/RoomHeader.tsx | 2 +- app/containers/RoomTypeIcon.tsx | 2 +- app/containers/Status/Status.tsx | 2 +- app/containers/TextInput.tsx | 6 +++++ app/containers/UIKit/MultiSelect/index.tsx | 3 ++- app/containers/markdown/List.tsx | 2 +- app/containers/message/index.tsx | 22 +++++++++++++++++++ app/presentation/RoomItem/RoomItem.tsx | 6 ++--- app/presentation/RoomItem/index.tsx | 11 ++++++++++ app/share.tsx | 1 + 17 files changed, 98 insertions(+), 26 deletions(-) diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index 84457cec0..8e0c51696 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -4693,7 +4693,7 @@ exports[`Storyshots List pressable 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 92, }, @@ -6211,7 +6211,7 @@ exports[`Storyshots List with bigger font 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 69, }, @@ -6625,7 +6625,7 @@ exports[`Storyshots List with bigger font 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 69, }, @@ -7080,7 +7080,7 @@ exports[`Storyshots List with black theme 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 92, }, @@ -7494,7 +7494,7 @@ exports[`Storyshots List with black theme 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 92, }, @@ -7972,7 +7972,7 @@ exports[`Storyshots List with custom colors 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 92, }, @@ -8129,7 +8129,7 @@ exports[`Storyshots List with dark theme 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 92, }, @@ -8543,7 +8543,7 @@ exports[`Storyshots List with dark theme 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 92, }, @@ -10410,7 +10410,7 @@ exports[`Storyshots List with small font 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 36.800000000000004, }, @@ -10824,7 +10824,7 @@ exports[`Storyshots List with small font 1`] = ` "justifyContent": "center", "paddingHorizontal": 12, }, - false, + undefined, Object { "height": 36.800000000000004, }, @@ -47791,6 +47791,7 @@ exports[`Storyshots Message With image 1`] = ` /> + //TODO - fix the required fields for the Markdown + //TODO - fix the required fields for the Markdown ) => { + if ((!text && !avatar && !emoji && !rid) || !server) { return null; } diff --git a/app/containers/Avatar/index.tsx b/app/containers/Avatar/index.tsx index dc58ef90d..981f19f60 100644 --- a/app/containers/Avatar/index.tsx +++ b/app/containers/Avatar/index.tsx @@ -12,6 +12,11 @@ class AvatarContainer extends React.Component, any> { private mounted: boolean; private subscription!: any; + static defaultProps = { + text: '', + type: 'd' + }; + constructor(props: Partial) { super(props); this.mounted = false; diff --git a/app/containers/Button/index.tsx b/app/containers/Button/index.tsx index 9faa12648..3ff63f5c0 100644 --- a/app/containers/Button/index.tsx +++ b/app/containers/Button/index.tsx @@ -40,6 +40,14 @@ const styles = StyleSheet.create({ export default class Button extends React.PureComponent, any> { + static defaultProps = { + title: 'Press me!', + type: 'primary', + onPress: () => alert('It works!'), + disabled: false, + loading: false + } + render() { const { title, type, onPress, disabled, backgroundColor, color, loading, style, theme, fontSize, ...otherProps diff --git a/app/containers/HeaderButton/HeaderButtonContainer.tsx b/app/containers/HeaderButton/HeaderButtonContainer.tsx index 3f704ebdc..ce6506b67 100644 --- a/app/containers/HeaderButton/HeaderButtonContainer.tsx +++ b/app/containers/HeaderButton/HeaderButtonContainer.tsx @@ -20,7 +20,7 @@ const styles = StyleSheet.create({ } }); -const Container = ({ children, left }: IHeaderButtonContainer) => ( +const Container = ({ children, left = false }: IHeaderButtonContainer) => ( {children} diff --git a/app/containers/LoginServices.tsx b/app/containers/LoginServices.tsx index 8c6695c46..84c36edd8 100644 --- a/app/containers/LoginServices.tsx +++ b/app/containers/LoginServices.tsx @@ -93,6 +93,10 @@ interface ILoginServicesProps { class LoginServices extends React.PureComponent { private _animation: any; + static defaultProps = { + separator: true + } + state = { collapsed: true, servicesHeight: new Animated.Value(SERVICES_COLLAPSED_HEIGHT) diff --git a/app/containers/MessageBox/index.tsx b/app/containers/MessageBox/index.tsx index 1693afdce..627ea4aea 100644 --- a/app/containers/MessageBox/index.tsx +++ b/app/containers/MessageBox/index.tsx @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { View, Alert, Keyboard, Text } from 'react-native'; +import {View, Alert, Keyboard, Text, NativeModules} from 'react-native'; import { connect } from 'react-redux'; import { KeyboardAccessoryView } from 'react-native-ui-lib/keyboard'; import ImagePicker from 'react-native-image-crop-picker'; @@ -143,6 +143,16 @@ class MessageBox extends Component { private component: any; private typingTimeout: any; + static defaultProps = { + message: { + id: '' + }, + sharing: false, + iOSScrollBehavior: NativeModules.KeyboardTrackingViewTempManager?.KeyboardTrackingScrollBehaviorFixedOffset, + isActionsEnabled: true, + getCustomEmoji: () => {} + } + constructor(props: IMessageBoxProps) { super(props); this.state = { @@ -958,6 +968,7 @@ class MessageBox extends Component { //@ts-ignore style={[styles.textBoxInput, { color: themes[theme].bodyText }]} returnKeyType='default' + //@ts-ignore keyboardType='twitter' blurOnSubmit={false} placeholder={I18n.t('New_Message')} diff --git a/app/containers/RoomHeader/RoomHeader.tsx b/app/containers/RoomHeader/RoomHeader.tsx index e2b71d6d8..fbe48cd6f 100644 --- a/app/containers/RoomHeader/RoomHeader.tsx +++ b/app/containers/RoomHeader/RoomHeader.tsx @@ -141,7 +141,7 @@ const HeaderTitle = React.memo(({ title, tmid, prid, scale, theme, testID }: TRo }); const Header = React.memo(({ - title, subtitle, parentTitle, type, status, usersTyping, width, height, prid, tmid, onPress, theme, isGroupChat, teamMain, testID + title, subtitle, parentTitle, type, status, width, height, prid, tmid, onPress, theme, isGroupChat, teamMain, testID, usersTyping = [] }: IRoomHeader) => { const portrait = height > width; let scale = 1; diff --git a/app/containers/RoomTypeIcon.tsx b/app/containers/RoomTypeIcon.tsx index 20a5a2ddd..459649a66 100644 --- a/app/containers/RoomTypeIcon.tsx +++ b/app/containers/RoomTypeIcon.tsx @@ -22,7 +22,7 @@ interface IRoomTypeIcon { } const RoomTypeIcon = React.memo(({ - type, size, isGroupChat, status, style, theme, teamMain + type, isGroupChat, status, style, theme, teamMain, size = 16 }: IRoomTypeIcon) => { if (!type) { return null; diff --git a/app/containers/Status/Status.tsx b/app/containers/Status/Status.tsx index 8aab83600..70ebd6229 100644 --- a/app/containers/Status/Status.tsx +++ b/app/containers/Status/Status.tsx @@ -8,7 +8,7 @@ interface IStatus { style: any; } -const Status = React.memo(({ status, size, style, ...props }: IStatus) => { +const Status = React.memo(({ style, status = 'offline', size = 32, ...props }: IStatus) => { const name = `status-${ status }`; const isNameValid = CustomIcon.hasIcon(name); const iconName = isNameValid ? name : 'status-offline'; diff --git a/app/containers/TextInput.tsx b/app/containers/TextInput.tsx index 90d5c33b0..7773fb423 100644 --- a/app/containers/TextInput.tsx +++ b/app/containers/TextInput.tsx @@ -72,6 +72,11 @@ interface IRCTextInputProps { export default class RCTextInput extends React.PureComponent { + static defaultProps = { + error: {}, + theme: 'light' + } + state = { showPassword: false } @@ -167,6 +172,7 @@ export default class RCTextInput extends React.PureComponent {}, disabled, inputStyle, theme @@ -129,6 +129,7 @@ export const MultiSelect = React.memo(({ { +const List = React.memo(({ children, ordered, tight, start = 1, numberOfLines = 0 }: IList) => { let bulletWidth = 15; if (ordered) { diff --git a/app/containers/message/index.tsx b/app/containers/message/index.tsx index 86a6a6e3d..8056c3682 100644 --- a/app/containers/message/index.tsx +++ b/app/containers/message/index.tsx @@ -64,6 +64,28 @@ interface IMessageContainerProps { class MessageContainer extends React.Component { + static defaultProps = { + getCustomEmoji: () => {}, + onLongPress: () => {}, + onReactionPress: () => {}, + onEncryptedPress: () => {}, + onDiscussionPress: () => {}, + onThreadPress: () => {}, + errorActionsShow: () => {}, + replyBroadcast: () => {}, + reactionInit: () => {}, + fetchThreadName: () => {}, + showAttachment: () => {}, + onReactionLongPress: () => {}, + navToRoomInfo: () => {}, + callJitsi: () => {}, + blockAction: () => {}, + archived: false, + broadcast: false, + isIgnored: false, + theme: 'light' + } + state = { isManualUnignored: false }; private subscription: any; diff --git a/app/presentation/RoomItem/RoomItem.tsx b/app/presentation/RoomItem/RoomItem.tsx index 6c8a58707..4cdc64c57 100644 --- a/app/presentation/RoomItem/RoomItem.tsx +++ b/app/presentation/RoomItem/RoomItem.tsx @@ -66,10 +66,10 @@ const RoomItem = ({ name, avatar, width, - avatarSize, + avatarSize = 48, username, showLastMessage, - status, + status = 'offline', useRealName, theme, isFocused, @@ -88,7 +88,7 @@ const RoomItem = ({ tunreadUser, tunreadGroup, testID, - swipeEnabled, + swipeEnabled = true, onPress, onLongPress, toggleFav, diff --git a/app/presentation/RoomItem/index.tsx b/app/presentation/RoomItem/index.tsx index 2116a5b8a..b7d22ab6f 100644 --- a/app/presentation/RoomItem/index.tsx +++ b/app/presentation/RoomItem/index.tsx @@ -50,6 +50,17 @@ class RoomItemContainer extends React.Component { private mounted: boolean; private roomSubscription: any; + static defaultProps = { + avatarSize: 48, + status: 'offline', + getUserPresence: () => {}, + getRoomTitle: () => 'title', + getRoomAvatar: () => '', + getIsGroupChat: () => false, + getIsRead: () => false, + swipeEnabled: true + } + constructor(props: IRoomItemContainerProps) { super(props); this.mounted = false; diff --git a/app/share.tsx b/app/share.tsx index e3448563d..998b3eafe 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -86,6 +86,7 @@ const OutsideStack = () => {