Skip to content

Commit

Permalink
fga-eps-mds#164 - Fixing profile screen tests
Browse files Browse the repository at this point in the history
Co-authored-by: Ronyell <ronyellhenrrique@gmail.com>
Co-authored-by: ThalissonMelo <tallisonmelo@hotmail.com>
  • Loading branch information
3 people committed Apr 23, 2018
1 parent dc15f3a commit caac5b0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
8 changes: 4 additions & 4 deletions __tests__/screens/ProfileInfoScreen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ describe('Testing ProfileInfoScreen', () => {
};
const wrapper = shallow(<ProfileInfoScreen {...myProps} />);

const foundPresident = wrapper.findWhere(c => c.key() === 'is_president');
const foundConselour = wrapper.findWhere(c => c.key() === 'is_counselor');
const foundPresident = wrapper.findWhere(c => c.text() === 'Presidente');
const foundConselour = wrapper.findWhere(c => c.text() === 'Conselheiro');

expect(foundPresident.length).toBe(1);
expect(foundConselour.length).toBe(0);
Expand All @@ -57,8 +57,8 @@ describe('Testing ProfileInfoScreen', () => {
};
const wrapper = shallow(<ProfileInfoScreen {...myProps} />);

const foundPresident = wrapper.findWhere(c => c.key() === 'is_president');
const foundConselour = wrapper.findWhere(c => c.key() === 'is_counselor');
const foundPresident = wrapper.findWhere(c => c.text() === 'Presidente');
const foundConselour = wrapper.findWhere(c => c.text() === 'Conselheiro');

expect(foundPresident.length).toBe(0);
expect(foundConselour.length).toBe(1);
Expand Down
2 changes: 1 addition & 1 deletion src/Styles/ProfileStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ const styles = StyleSheet.create({
},
});

export default styles;
export default styles;
18 changes: 14 additions & 4 deletions src/components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import styles from '../Styles/GeneralStyles';

class Button extends React.Component {
defineStyle() {
if (this.props.style === undefined) {
this.props.style.text = styles.buttonText;
if (!this.props.style) {
if (this.props.enabled) {
return (
styles.bigButton
Expand All @@ -22,6 +21,13 @@ class Button extends React.Component {
);
}

defineTextStyle() {
if (!this.props.style) {
return styles.buttonText;
}
return this.props.style.text;
}

render() {
return (
<View>
Expand All @@ -31,7 +37,7 @@ class Button extends React.Component {
disabled={!this.props.enabled}
onPress={() => this.props.onPress()}
>
<Text style={this.props.style.text}>{this.props.text}</Text>
<Text style={this.defineTextStyle()}>{this.props.text}</Text>
</TouchableOpacity>
</View>
);
Expand All @@ -45,7 +51,11 @@ Button.propTypes = {
text: string.isRequired,
enabled: bool.isRequired,
onPress: func.isRequired,
style: element.isRequired,
style: element,
};

Button.defaultProps = {
style: undefined,
};

export default Button;
6 changes: 5 additions & 1 deletion src/components/ScheduleCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ ScheduleCard.propTypes = {
value: PropTypes.string.isRequired,
})).isRequired,
keyProp: PropTypes.string.isRequired,
children: PropTypes.element.isRequired,
children: PropTypes.element,
};

ScheduleCard.defaultProps = {
children: undefined,
};

export default ScheduleCard;
4 changes: 2 additions & 2 deletions src/screens/ProfileInfoScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { MaterialIcons } from '@expo/vector-icons';
import Header from '../components/Header';
import Button from '../components/Button';
import { backHandlerPopToMain } from '../NavigationFunctions';
import { PROFILE_FIELDS } from '../constants/profileInformations';
import { styles } from '../Styles/ProfileStyles';
import PROFILE_FIELDS from '../constants/profileInformations';
import styles from '../Styles/ProfileStyles';


export default class ProfileInfoScreen extends React.Component {
Expand Down
4 changes: 2 additions & 2 deletions src/screens/scheduleMeeting/ScheduleMeeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ ScheduleMeeting.propTypes = {
phone: string.isRequired,
}).isRequired,
meetingListOfInvitees: shape({
nuvemCode: number.isRequired,
confirmed: bool.isRequired,
nuvemCode: number,
confirmed: bool,
}).isRequired,
};

0 comments on commit caac5b0

Please sign in to comment.