...
 
Commits (3)
export default {
};
export const withNavigation = jest.fn();
export const Header = {
HEIGHT:80
}
export const StackActions = {
reset: jest.fn()
}
export const NavigationActions = {
navigate: jest.fn(),
setParams: jest.fn(),
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import { Text, TouchableOpacity } from "react-native";
import { shallow } from 'enzyme';
import RegisterScreen from '../../src/auth/RegisterScreen';
import { NavigationActions, StackActions } from 'react-navigation';
jest.mock('../../src/auth/RegisterForm', () => 'RegisterForm');
jest.mock('../../src/common/components/VideoBackground', () => 'VideoBackground');
......@@ -41,6 +42,8 @@ describe('RegisterScreen component', () => {
<RegisterScreen navigation={navigation}/>
);
StackActions.reset.mockReturnValue(1)
// find register form
const registerForms = wrapper.find('RegisterForm');
......@@ -51,9 +54,9 @@ describe('RegisterScreen component', () => {
registerForms.at(0).props().onBack();
// should call navigate
expect(navigation.dispatch.mock.calls.length).toEqual(1);
expect(StackActions.reset).toBeCalledWith({"actions": [undefined], "index": 0});
// with a navigation action with route to Login
expect(navigation.dispatch.mock.calls[0][0].actions[0].routeName).toEqual('Login');
expect(NavigationActions.navigate).toBeCalledWith({"routeName": "Login"});
});
});
......@@ -877,6 +877,7 @@ exports[`blog view screen component should renders correctly 1`] = `
</SafeAreaView>
</View>
}
keyboardVerticalOffset={15}
navigation={
Object {
"state": Object {
......
......@@ -432,9 +432,10 @@ describe('cature poster component', () => {
expect(capture.post).toHaveBeenCalled();
// should be called only once
expect(capture.post.mock.calls.length).toBe(1);
expect(capture.post).toBeCalled();
// should send the attachment data
console.log(capture.post.mock.calls);
expect(capture.post.mock.calls[0][0]).toEqual({
nsfw: [],
message: "some awesome post",
......
......@@ -21,6 +21,8 @@ import {
Alert,
} from 'react-native';
import { Header } from 'react-navigation';
import { inject, observer } from 'mobx-react/native';
import FastImage from 'react-native-fast-image';
......@@ -174,6 +176,7 @@ export default class BlogsViewScreen extends Component {
entity={this.props.blogsView.blog}
store={this.comments}
navigation={this.props.navigation}
keyboardVerticalOffset = {Header.HEIGHT - 65}
/>
:
<View style={CS.flexColumnCentered}>
......
......@@ -155,14 +155,13 @@ export default class CommentList extends React.Component<Props, State> {
setTimeout(() => {
this.listRef.scrollToIndex({
index: this.focusedChild,
viewOffset: this.focusedOffset ? -(this.focusedOffset - (this.height - e.endCoordinates.height - 70)) : -e.endCoordinates.height + 70,
viewOffset: this.focusedOffset ? -(this.focusedOffset - (this.height - e.endCoordinates.height - 110)) : -110 ,
viewPosition: this.focusedOffset ? 0 : 1
});
}, 200);
}
} else {
if (!this.state.focused) this.setState({hideInput: true});
}
}
// this.scrollBottomIfNeeded();
}
......@@ -171,7 +170,7 @@ export default class CommentList extends React.Component<Props, State> {
* On keyboard hide
*/
_keyboardDidHide = (e) => {
if (!this.props.parent && !isIOS) {
if (!this.props.parent) {
this.setState({hideInput: false});
}
}
......@@ -230,6 +229,8 @@ export default class CommentList extends React.Component<Props, State> {
if (!this.props.parent) {
this.focusedChild = comments.findIndex(c => item === c);
this.focusedOffset = offset;
this.setState({hideInput: true});
//this.forceUpdate();
} else {
const index = comments.findIndex(c => item === c);
const frame = this.listRef._listRef._getFrameMetricsApprox(index);
......@@ -498,7 +499,7 @@ export default class CommentList extends React.Component<Props, State> {
return (
<View style={[CS.flexContainer, CS.backgroundWhite, paddingBottom]} onLayout={this.onLayout}>
<KeyboardAvoidingView style={[CS.flexContainer]} behavior={Platform.OS == 'ios' ? 'padding' : null}
keyboardVerticalOffset={vPadding} enabled={this.state.focused && !this.props.parent}>
keyboardVerticalOffset={this.props.keyboardVerticalOffset ? -this.props.keyboardVerticalOffset : vPadding} enabled={!this.props.parent ? (this.state.focused || this.focusedChild !== -1) : false}>
<View style={CS.flexContainer}>
<FlatList
ref={this.setListRef}
......
......@@ -9,9 +9,12 @@ import {
FlatList,
ScrollView,
Alert,
SafeAreaView
SafeAreaView,
Platform,
} from 'react-native';
import { Header } from 'react-navigation';
import {
observer,
inject
......@@ -64,7 +67,7 @@ export default class GroupViewScreen extends Component {
* Disable navigation bar
*/
static navigationOptions = {
header: null
header: null,
}
/**
......@@ -199,6 +202,7 @@ export default class GroupViewScreen extends Component {
entity={group.group}
store={this.comments}
navigation={this.props.navigation}
keyboardVerticalOffset = {Header.HEIGHT - 65}
/>
);
case 'desc':
......