Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

Commit

Permalink
Fixed test and update snapshot.
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Dec 30, 2018
1 parent f3a17c0 commit 057d88b
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 117 deletions.
4 changes: 2 additions & 2 deletions src/components/screen/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ class Screen extends Component<Props, State> {
<View style={styles.viewBtnWrapper}>
<Button
constainerStyle={{ flex: 1 }}
onPress={this.goToSignup}
onPress={() => this.goToSignup()}
style={styles.btnSignup}
textStyle={styles.txtSignUp}
>{getString('SIGNUP')}</Button>
<View style={{ width: 8 }}/>
<Button
constainerStyle={{ flex: 1 }}
isLoading={this.state.isLoggingIn}
onPress={this.onLogin}
onPress={() => this.onLogin()}
style={styles.btnLogin}
textStyle={styles.txtLogin}
>{getString('LOGIN')}</Button>
Expand Down
11 changes: 4 additions & 7 deletions src/components/screen/__tests__/Login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,14 @@ describe('interaction', () => {
spy2 = jest.spyOn(wrapper.instance(), 'onLogin');
})
it('should call onLogin callback', () => {
const signupBtn = wrapper.find(Button).first();
const loginBtn = wrapper.find(Button).last();
expect(signupBtn).toHaveLength(1);
expect(loginBtn).toHaveLength(1);
const signupBtn = wrapper.find(Button).at(0);
const loginBtn = wrapper.find(Button).at(1);
signupBtn.props().onPress();
console.warn(signupBtn.props().onPress());
loginBtn.props().onPress();

// TODO: currently not beening called
// expect(spy1).toHaveBeenCalled();
// expect(spy2).toBeCalled();
expect(spy1).toHaveBeenCalled();
expect(spy2).toBeCalled();
});
});
afterAll(() => {
Expand Down
30 changes: 21 additions & 9 deletions src/components/screen/__tests__/__snapshots__/Login.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exports[`rendering test renders as expected 1`] = `
"alignItems": "center",
"flex": 1,
"flexDirection": "column",
"paddingTop": 20,
}
}
>
Expand Down Expand Up @@ -100,13 +99,19 @@ exports[`rendering test renders as expected 1`] = `
"alignItems": "center",
"alignSelf": "stretch",
"flexDirection": "row",
"justifyContent": "flex-end",
"height": 60,
"justifyContent": "space-between",
"marginTop": 20,
}
}
>
<Button
activeOpacity={0.5}
constainerStyle={
Object {
"flex": 1,
}
}
imgLeftStyle={
Object {
"height": 24,
Expand All @@ -122,15 +127,13 @@ exports[`rendering test renders as expected 1`] = `
style={
Object {
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "transparent",
"borderColor": "rgb(58,139,255)",
"borderRadius": 4,
"borderWidth": 1,
"height": 60,
"height": "100%",
"justifyContent": "center",
"marginRight": 4,
"width": 136,
"width": "100%",
}
}
textStyle={
Expand All @@ -143,8 +146,20 @@ exports[`rendering test renders as expected 1`] = `
>
SIGN UP
</Button>
<View
style={
Object {
"width": 8,
}
}
/>
<Button
activeOpacity={0.5}
constainerStyle={
Object {
"flex": 1,
}
}
imgLeftStyle={
Object {
"height": 24,
Expand All @@ -160,22 +175,19 @@ exports[`rendering test renders as expected 1`] = `
style={
Object {
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "rgb(58,139,255)",
"borderColor": "rgb(58,139,255)",
"borderRadius": 4,
"borderWidth": 1,
"height": 60,
"justifyContent": "center",
"marginLeft": 4,
"shadowColor": "rgb(58,139,255)",
"shadowOffset": Object {
"height": 10,
"width": 0,
},
"shadowOpacity": 0.3,
"shadowRadius": 4,
"width": 136,
}
}
textStyle={
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/__tests__/Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Button', () => {
wrapper.setProps({ onPress: () => onPress()});
expect(wrapper).toMatchSnapshot();

wrapper.first().props().onPress();
wrapper.find('TouchableOpacity').props().onPress();
expect(cnt).toBe(2);
});
});
Expand Down
204 changes: 106 additions & 98 deletions src/components/shared/__tests__/__snapshots__/Button.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,138 +1,146 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Button component test renders as expected 1`] = `
<TouchableOpacity
activeOpacity={0.5}
>
<View
style={
Object {
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "transparent",
"borderColor": "white",
"borderRadius": 4,
"borderWidth": 2,
"height": 52,
"justifyContent": "center",
"width": 320,
}
}
<View>
<TouchableOpacity
activeOpacity={0.5}
>
<Text
<View
style={
Object {
"color": "white",
"fontSize": 14,
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "transparent",
"borderColor": "white",
"borderRadius": 4,
"borderWidth": 2,
"height": "100%",
"justifyContent": "center",
"width": "100%",
}
}
/>
</View>
</TouchableOpacity>
>
<Text
style={
Object {
"color": "white",
"fontSize": 14,
}
}
/>
</View>
</TouchableOpacity>
</View>
`;

exports[`Button component test renders as expected 2`] = `
<TouchableOpacity
activeOpacity={0.5}
>
<View
style={
Object {
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "transparent",
"borderColor": "white",
"borderRadius": 4,
"borderWidth": 2,
"height": 52,
"justifyContent": "center",
"width": 320,
}
}
<View>
<TouchableOpacity
activeOpacity={0.5}
>
<Text
<View
style={
Object {
"color": "white",
"fontSize": 14,
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "transparent",
"borderColor": "white",
"borderRadius": 4,
"borderWidth": 2,
"height": "100%",
"justifyContent": "center",
"width": "100%",
}
}
/>
</View>
</TouchableOpacity>
>
<Text
style={
Object {
"color": "white",
"fontSize": 14,
}
}
/>
</View>
</TouchableOpacity>
</View>
`;

exports[`Button component test simulate onPress 1`] = `
<TouchableOpacity
activeOpacity={0.5}
onPress={[Function]}
>
<View
style={
Object {
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "transparent",
"borderColor": "white",
"borderRadius": 4,
"borderWidth": 2,
"height": 52,
"justifyContent": "center",
"width": 320,
}
}
<View>
<TouchableOpacity
activeOpacity={0.5}
onPress={[Function]}
>
<Text
<View
style={
Object {
"color": "white",
"fontSize": 14,
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "transparent",
"borderColor": "white",
"borderRadius": 4,
"borderWidth": 2,
"height": "100%",
"justifyContent": "center",
"width": "100%",
}
}
/>
</View>
</TouchableOpacity>
>
<Text
style={
Object {
"color": "white",
"fontSize": 14,
}
}
/>
</View>
</TouchableOpacity>
</View>
`;

exports[`Button renders without crashing 1`] = `
<View
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
}
>
<View>
<View
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "transparent",
"borderColor": "white",
"borderRadius": 4,
"borderWidth": 2,
"height": 52,
"justifyContent": "center",
"width": 320,
"opacity": 1,
}
}
>
<Text
<View
style={
Object {
"color": "white",
"fontSize": 14,
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "transparent",
"borderColor": "white",
"borderRadius": 4,
"borderWidth": 2,
"height": "100%",
"justifyContent": "center",
"width": "100%",
}
}
/>
>
<Text
style={
Object {
"color": "white",
"fontSize": 14,
}
}
/>
</View>
</View>
</View>
`;

0 comments on commit 057d88b

Please sign in to comment.