Browse Source

fixed tests, refactored

Daniel Zlotin 8 years ago
parent
commit
b72f19f975

+ 1
- 1
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ApplicationLifecycleTest.java View File

141
     }
141
     }
142
 
142
 
143
     private void assertPushedScreenShown() {
143
     private void assertPushedScreenShown() {
144
-        assertExists(By.text("Pushed screen"));
144
+        assertExists(By.text("Pushed Screen"));
145
     }
145
     }
146
 }
146
 }

+ 11
- 11
playground/e2e/app.test.js View File

15
 
15
 
16
   it('push screen', () => {
16
   it('push screen', () => {
17
     elementByLabel('Push').tap();
17
     elementByLabel('Push').tap();
18
-    expect(elementByLabel('Pushed screen')).toBeVisible();
18
+    expect(elementByLabel('Pushed Screen')).toBeVisible();
19
   });
19
   });
20
 
20
 
21
   it('switch to tabs with side menus', () => {
21
   it('switch to tabs with side menus', () => {
22
     elementByLabel('Switch to app with side menus').tap();
22
     elementByLabel('Switch to app with side menus').tap();
23
-    elementByLabel('This is a side menu center screen').swipe('right');
24
-    expect(elementByLabel('This is a side menu screen')).toBeVisible();
23
+    elementByLabel('This is a side menu center screen tab 1').swipe('right');
24
+    expect(elementByLabel('This is a left side menu screen')).toBeVisible();
25
   });
25
   });
26
 
26
 
27
   it('screen lifecycle', () => {
27
   it('screen lifecycle', () => {
34
 
34
 
35
   it('pop screen', () => {
35
   it('pop screen', () => {
36
     elementByLabel('Push').tap();
36
     elementByLabel('Push').tap();
37
-    expect(elementByLabel('Pushed screen')).toBeVisible();
37
+    expect(elementByLabel('Pushed Screen')).toBeVisible();
38
     elementByLabel('Pop').tap();
38
     elementByLabel('Pop').tap();
39
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
39
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
40
   });
40
   });
41
 
41
 
42
   it('show modal', () => {
42
   it('show modal', () => {
43
     elementByLabel('Show Modal').tap();
43
     elementByLabel('Show Modal').tap();
44
-    expect(elementByLabel('Modal screen')).toBeVisible();
44
+    expect(elementByLabel('Modal Screen')).toBeVisible();
45
   });
45
   });
46
 
46
 
47
   it('dismiss modal', () => {
47
   it('dismiss modal', () => {
48
     elementByLabel('Show Modal').tap();
48
     elementByLabel('Show Modal').tap();
49
-    expect(elementByLabel('Modal screen')).toBeVisible();
49
+    expect(elementByLabel('Modal Screen')).toBeVisible();
50
     elementByLabel('Dismiss Modal').tap();
50
     elementByLabel('Dismiss Modal').tap();
51
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
51
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
52
   });
52
   });
53
-  
54
-  it.only('show multiple modals', () => {
53
+
54
+  xit('show multiple modals', () => {
55
     elementByLabel('Show Modal').tap();
55
     elementByLabel('Show Modal').tap();
56
-    expect(elementByLabel('ModalStackPosition: 1')).toBeVisible();
56
+    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
57
     elementByLabel('Show Modal').tap();
57
     elementByLabel('Show Modal').tap();
58
-    expect(elementByLabel('ModalStackPosition: 2s')).toBeVisible();
59
-  })
58
+    expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
59
+  });
60
 });
60
 });
61
 
61
 
62
 describe('reload app', () => {
62
 describe('reload app', () => {

+ 2
- 2
playground/src/containers/LifecycleScreen.js View File

23
   render() {
23
   render() {
24
     return (
24
     return (
25
       <View style={styles.root}>
25
       <View style={styles.root}>
26
-        <Text style={styles.h1}>Lifecycle Screen</Text>
26
+        <Text style={styles.h1}>{`Lifecycle Screen`}</Text>
27
         <Text style={styles.h1}>{this.state.text}</Text>
27
         <Text style={styles.h1}>{this.state.text}</Text>
28
         <Button title="Push to test onStop" onPress={this.onClickPush} />
28
         <Button title="Push to test onStop" onPress={this.onClickPush} />
29
-        <Text style={styles.footer}>ContainerId: {this.props.id}</Text>
29
+        <Text style={styles.footer}>{`this.props.id = ${this.props.id}`}</Text>
30
       </View>
30
       </View>
31
     );
31
     );
32
   }
32
   }

+ 11
- 7
playground/src/containers/ModalScreen.js View File

1
-import React, {Component} from 'react';
1
+import React, { Component } from 'react';
2
 import {
2
 import {
3
   StyleSheet,
3
   StyleSheet,
4
   View,
4
   View,
17
   render() {
17
   render() {
18
     return (
18
     return (
19
       <View style={styles.root}>
19
       <View style={styles.root}>
20
-        <Text style={styles.h1}>Modal Screen</Text>
21
-        <Text style={styles.footer}>ModalStackPosition: {this.props.modalPosition || 1}</Text>
20
+        <Text style={styles.h1}>{`Modal Screen`}</Text>
21
+        <Text style={styles.footer}>{`Modal Stack Position: ${this.getModalPosition()}`}</Text>
22
         <Button title="Show Modal" onPress={this.onClickShowModal} />
22
         <Button title="Show Modal" onPress={this.onClickShowModal} />
23
         <Button title="Dismiss Modal" onPress={this.onClickDismissModal} />
23
         <Button title="Dismiss Modal" onPress={this.onClickDismissModal} />
24
-        <Text style={styles.footer}>ContainerId: {this.props.id}</Text>
24
+        <Text style={styles.footer}>{`this.props.id = ${this.props.id}`}</Text>
25
       </View>
25
       </View>
26
     );
26
     );
27
   }
27
   }
28
-  
28
+
29
   onClickShowModal() {
29
   onClickShowModal() {
30
     Navigation.showModal({
30
     Navigation.showModal({
31
       name: 'navigation.playground.ModalScreen',
31
       name: 'navigation.playground.ModalScreen',
32
       passProps: {
32
       passProps: {
33
-        modalPosition: (this.props.modalPosition || 1) + 1
33
+        modalPosition: this.getModalPosition() + 1
34
       }
34
       }
35
     });
35
     });
36
   }
36
   }
37
-  
37
+
38
   onClickDismissModal() {
38
   onClickDismissModal() {
39
     Navigation.dismissModal(this.props.id);
39
     Navigation.dismissModal(this.props.id);
40
   }
40
   }
41
+
42
+  getModalPosition() {
43
+    return (this.props.modalPosition || 1);
44
+  }
41
 }
45
 }
42
 
46
 
43
 const styles = {
47
 const styles = {

+ 11
- 7
playground/src/containers/PushedScreen.js View File

1
-import React, {Component} from 'react';
1
+import React, { Component } from 'react';
2
 import {
2
 import {
3
   StyleSheet,
3
   StyleSheet,
4
   View,
4
   View,
17
   render() {
17
   render() {
18
     return (
18
     return (
19
       <View style={styles.root}>
19
       <View style={styles.root}>
20
-        <Text style={styles.h1}>Pushed Screen</Text>
21
-        <Text style={styles.h2}>Stack Position: {this.props.stackPosition || 1}</Text>
20
+        <Text style={styles.h1}>{`Pushed Screen`}</Text>
21
+        <Text style={styles.h2}>{`Stack Position: ${this.getStackPosition()}`}</Text>
22
         <Button title="Push" onPress={this.onClickPush} />
22
         <Button title="Push" onPress={this.onClickPush} />
23
         <Button title="Pop" onPress={this.onClickPop} />
23
         <Button title="Pop" onPress={this.onClickPop} />
24
-        <Text style={styles.footer}>ContainerId: {this.props.id}</Text>
24
+        <Text style={styles.footer}>{`this.props.id = ${this.props.id}`}</Text>
25
       </View>
25
       </View>
26
     );
26
     );
27
   }
27
   }
28
-  
28
+
29
   onClickPush() {
29
   onClickPush() {
30
     Navigation.on(this.props.id).push({
30
     Navigation.on(this.props.id).push({
31
       name: 'navigation.playground.PushedScreen',
31
       name: 'navigation.playground.PushedScreen',
32
       passProps: {
32
       passProps: {
33
-        stackPosition: (this.props.stackPosition || 1) + 1
33
+        stackPosition: this.getStackPosition() + 1
34
       }
34
       }
35
     });
35
     });
36
   }
36
   }
37
-  
37
+
38
   onClickPop() {
38
   onClickPop() {
39
     Navigation.on(this.props.id).pop();
39
     Navigation.on(this.props.id).pop();
40
   }
40
   }
41
+
42
+  getStackPosition() {
43
+    return this.props.stackPosition || 1;
44
+  }
41
 }
45
 }
42
 
46
 
43
 const styles = {
47
 const styles = {

+ 0
- 84
playground/src/containers/SimpleScreen.js View File

1
-//import React, { Component } from 'react';
2
-//import { View, Text, Button } from 'react-native';
3
-//
4
-//import Navigation from 'react-native-navigation';
5
-//
6
-//class SimpleScreen extends Component {
7
-//  constructor(props) {
8
-//    super(props);
9
-//    this.onClickPop = this.onClickPop.bind(this);
10
-//    this.onClickPush = this.onClickPush.bind(this);
11
-//    this.onClickShowModal = this.onClickShowModal.bind(this);
12
-//    this.onClickDismissModal = this.onClickDismissModal.bind(this);
13
-//  }
14
-//
15
-//  render() {
16
-//    return (
17
-//      <View style={styles.root}>
18
-//        <Text style={styles.h1}>{'Simple Screen'}</Text>
19
-//        <Text style={styles.h1}>Origin: {this.props.origin}</Text>
20
-//        <Text style={styles.h2}>Stack Position: {this.props.stackPosition}</Text>
21
-//        {this.renderTextFromFunctionInProps()}
22
-//        <Button title="Push" onPress={this.onClickPush} />
23
-//        <Button title="Pop" onPress={this.onClickPop} />
24
-//        <Button title="Show Modal" onPress={this.onClickPop} />
25
-//        <Button title="Dismiss Modal" onPress={this.onClickDismissModal} />
26
-//      </View>
27
-//    );
28
-//  }
29
-//
30
-//  renderTextFromFunctionInProps() {
31
-//    if (!this.props.myFunction) {
32
-//      return undefined;
33
-//    }
34
-//    return (
35
-//      <Text style={styles.h1}>{this.props.myFunction()}</Text>
36
-//    );
37
-//  }
38
-//
39
-//  onClickPop() {
40
-//    Navigation.on(this.props.id).pop();
41
-//  }
42
-//
43
-//  onClickPush() {
44
-//    Navigation.on(this.props.id).push({
45
-//      name: 'navigation.playground.SimpleScreen',
46
-//      passProps: {
47
-//        stackPosition: this.props.stackPosition + 1
48
-//      }
49
-//    });
50
-//  }
51
-//
52
-//  onClickShowModal() {
53
-//    Navigation.showModal({
54
-//      name: 'navigation.playground.SimpleScreen',
55
-//      passProps: {
56
-//        text: 'Modal screen'
57
-//      }
58
-//    });
59
-//  }
60
-//
61
-//  onClickDismissModal() {
62
-//    Navigation.dismissModal(this.props.id);
63
-//  }
64
-//}
65
-//export default SimpleScreen;
66
-//
67
-//const styles = {
68
-//  root: {
69
-//    flexGrow: 1,
70
-//    justifyContent: 'center',
71
-//    alignItems: 'center',
72
-//    backgroundColor: '#f5fcff'
73
-//  },
74
-//  h1: {
75
-//    fontSize: 24,
76
-//    textAlign: 'center',
77
-//    margin: 10
78
-//  },
79
-//  h2: {
80
-//    fontSize: 12,
81
-//    textAlign: 'center',
82
-//    margin: 10
83
-//  }
84
-//};

+ 12
- 5
playground/src/containers/TextScreen.js View File

1
-import React, {Component} from 'react';
1
+import React, { Component } from 'react';
2
 import {
2
 import {
3
   StyleSheet,
3
   StyleSheet,
4
   View,
4
   View,
5
   Text
5
   Text
6
 } from 'react-native';
6
 } from 'react-native';
7
 
7
 
8
-
9
 class TextScreen extends Component {
8
 class TextScreen extends Component {
10
-  
11
   render() {
9
   render() {
12
     return (
10
     return (
13
       <View style={styles.root}>
11
       <View style={styles.root}>
14
         <Text style={styles.h1}>{this.props.text || 'Text Screen'}</Text>
12
         <Text style={styles.h1}>{this.props.text || 'Text Screen'}</Text>
15
-        <Text style={styles.footer}>ContainerId: {this.props.id}</Text>
13
+        {this.renderTextFromFunctionInProps()}
14
+        <Text style={styles.footer}>{`this.props.id = ${this.props.id}`}</Text>
16
       </View>
15
       </View>
17
     );
16
     );
18
   }
17
   }
18
+
19
+  renderTextFromFunctionInProps() {
20
+    if (!this.props.myFunction) {
21
+      return undefined;
22
+    }
23
+    return (
24
+      <Text style={styles.h1}>{this.props.myFunction()}</Text>
25
+    );
26
+  }
19
 }
27
 }
20
 
28
 
21
 const styles = {
29
 const styles = {
42
   }
50
   }
43
 };
51
 };
44
 
52
 
45
-
46
 export default TextScreen;
53
 export default TextScreen;

+ 15
- 6
playground/src/containers/WelcomeScreen.js View File

56
           container: {
56
           container: {
57
             name: 'navigation.playground.TextScreen',
57
             name: 'navigation.playground.TextScreen',
58
             passProps: {
58
             passProps: {
59
-              text: 'This is a side menu center screen'
59
+              text: 'This is a side menu center screen tab 1'
60
             }
60
             }
61
           }
61
           }
62
         },
62
         },
63
         {
63
         {
64
           container: {
64
           container: {
65
-            name: 'navigation.playground.TextScreen'
65
+            name: 'navigation.playground.TextScreen',
66
+            passProps: {
67
+              text: 'This is a side menu center screen tab 2'
68
+            }
66
           }
69
           }
67
         },
70
         },
68
         {
71
         {
69
           container: {
72
           container: {
70
-            name: 'navigation.playground.TextScreen'
73
+            name: 'navigation.playground.TextScreen',
74
+            passProps: {
75
+              text: 'This is a side menu center screen tab 3'
76
+            }
71
           }
77
           }
72
         }
78
         }
73
       ],
79
       ],
76
           container: {
82
           container: {
77
             name: 'navigation.playground.TextScreen',
83
             name: 'navigation.playground.TextScreen',
78
             passProps: {
84
             passProps: {
79
-              text: 'This is a side menu screen'
85
+              text: 'This is a left side menu screen'
80
             }
86
             }
81
           }
87
           }
82
         },
88
         },
83
         right: {
89
         right: {
84
           container: {
90
           container: {
85
-            name: 'navigation.playground.TextScreen'
91
+            name: 'navigation.playground.TextScreen',
92
+            passProps: {
93
+              text: 'This is a right side menu screen'
94
+            }
86
           }
95
           }
87
         }
96
         }
88
       }
97
       }
105
 
114
 
106
   onClickShowModal() {
115
   onClickShowModal() {
107
     Navigation.showModal({
116
     Navigation.showModal({
108
-      name: 'navigation.playground.ModalScreen',
117
+      name: 'navigation.playground.ModalScreen'
109
     });
118
     });
110
   }
119
   }
111
 
120
 

+ 0
- 1
playground/src/containers/index.js View File

6
 import LifecycleScreen from './LifecycleScreen';
6
 import LifecycleScreen from './LifecycleScreen';
7
 import ModalScreen from './ModalScreen';
7
 import ModalScreen from './ModalScreen';
8
 
8
 
9
-
10
 export function registerContainers() {
9
 export function registerContainers() {
11
   Navigation.registerContainer(`navigation.playground.WelcomeScreen`, () => WelcomeScreen);
10
   Navigation.registerContainer(`navigation.playground.WelcomeScreen`, () => WelcomeScreen);
12
   Navigation.registerContainer(`navigation.playground.ModalScreen`, () => ModalScreen);
11
   Navigation.registerContainer(`navigation.playground.ModalScreen`, () => ModalScreen);