Browse Source

fixed tests, refactored

Daniel Zlotin 7 years ago
parent
commit
b72f19f975

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

@@ -141,6 +141,6 @@ public class ApplicationLifecycleTest {
141 141
     }
142 142
 
143 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,13 +15,13 @@ describe('app', () => {
15 15
 
16 16
   it('push screen', () => {
17 17
     elementByLabel('Push').tap();
18
-    expect(elementByLabel('Pushed screen')).toBeVisible();
18
+    expect(elementByLabel('Pushed Screen')).toBeVisible();
19 19
   });
20 20
 
21 21
   it('switch to tabs with side menus', () => {
22 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 27
   it('screen lifecycle', () => {
@@ -34,29 +34,29 @@ describe('app', () => {
34 34
 
35 35
   it('pop screen', () => {
36 36
     elementByLabel('Push').tap();
37
-    expect(elementByLabel('Pushed screen')).toBeVisible();
37
+    expect(elementByLabel('Pushed Screen')).toBeVisible();
38 38
     elementByLabel('Pop').tap();
39 39
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
40 40
   });
41 41
 
42 42
   it('show modal', () => {
43 43
     elementByLabel('Show Modal').tap();
44
-    expect(elementByLabel('Modal screen')).toBeVisible();
44
+    expect(elementByLabel('Modal Screen')).toBeVisible();
45 45
   });
46 46
 
47 47
   it('dismiss modal', () => {
48 48
     elementByLabel('Show Modal').tap();
49
-    expect(elementByLabel('Modal screen')).toBeVisible();
49
+    expect(elementByLabel('Modal Screen')).toBeVisible();
50 50
     elementByLabel('Dismiss Modal').tap();
51 51
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
52 52
   });
53
-  
54
-  it.only('show multiple modals', () => {
53
+
54
+  xit('show multiple modals', () => {
55 55
     elementByLabel('Show Modal').tap();
56
-    expect(elementByLabel('ModalStackPosition: 1')).toBeVisible();
56
+    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
57 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 62
 describe('reload app', () => {

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

@@ -23,10 +23,10 @@ class LifecycleScreen extends Component {
23 23
   render() {
24 24
     return (
25 25
       <View style={styles.root}>
26
-        <Text style={styles.h1}>Lifecycle Screen</Text>
26
+        <Text style={styles.h1}>{`Lifecycle Screen`}</Text>
27 27
         <Text style={styles.h1}>{this.state.text}</Text>
28 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 30
       </View>
31 31
     );
32 32
   }

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

@@ -1,4 +1,4 @@
1
-import React, {Component} from 'react';
1
+import React, { Component } from 'react';
2 2
 import {
3 3
   StyleSheet,
4 4
   View,
@@ -17,27 +17,31 @@ class ModalScreen extends Component {
17 17
   render() {
18 18
     return (
19 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 22
         <Button title="Show Modal" onPress={this.onClickShowModal} />
23 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 25
       </View>
26 26
     );
27 27
   }
28
-  
28
+
29 29
   onClickShowModal() {
30 30
     Navigation.showModal({
31 31
       name: 'navigation.playground.ModalScreen',
32 32
       passProps: {
33
-        modalPosition: (this.props.modalPosition || 1) + 1
33
+        modalPosition: this.getModalPosition() + 1
34 34
       }
35 35
     });
36 36
   }
37
-  
37
+
38 38
   onClickDismissModal() {
39 39
     Navigation.dismissModal(this.props.id);
40 40
   }
41
+
42
+  getModalPosition() {
43
+    return (this.props.modalPosition || 1);
44
+  }
41 45
 }
42 46
 
43 47
 const styles = {

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

@@ -1,4 +1,4 @@
1
-import React, {Component} from 'react';
1
+import React, { Component } from 'react';
2 2
 import {
3 3
   StyleSheet,
4 4
   View,
@@ -17,27 +17,31 @@ class PushedScreen extends Component {
17 17
   render() {
18 18
     return (
19 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 22
         <Button title="Push" onPress={this.onClickPush} />
23 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 25
       </View>
26 26
     );
27 27
   }
28
-  
28
+
29 29
   onClickPush() {
30 30
     Navigation.on(this.props.id).push({
31 31
       name: 'navigation.playground.PushedScreen',
32 32
       passProps: {
33
-        stackPosition: (this.props.stackPosition || 1) + 1
33
+        stackPosition: this.getStackPosition() + 1
34 34
       }
35 35
     });
36 36
   }
37
-  
37
+
38 38
   onClickPop() {
39 39
     Navigation.on(this.props.id).pop();
40 40
   }
41
+
42
+  getStackPosition() {
43
+    return this.props.stackPosition || 1;
44
+  }
41 45
 }
42 46
 
43 47
 const styles = {

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

@@ -1,84 +0,0 @@
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,21 +1,29 @@
1
-import React, {Component} from 'react';
1
+import React, { Component } from 'react';
2 2
 import {
3 3
   StyleSheet,
4 4
   View,
5 5
   Text
6 6
 } from 'react-native';
7 7
 
8
-
9 8
 class TextScreen extends Component {
10
-  
11 9
   render() {
12 10
     return (
13 11
       <View style={styles.root}>
14 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 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 29
 const styles = {
@@ -42,5 +50,4 @@ const styles = {
42 50
   }
43 51
 };
44 52
 
45
-
46 53
 export default TextScreen;

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

@@ -56,18 +56,24 @@ class WelcomeScreen extends Component {
56 56
           container: {
57 57
             name: 'navigation.playground.TextScreen',
58 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 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 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,13 +82,16 @@ class WelcomeScreen extends Component {
76 82
           container: {
77 83
             name: 'navigation.playground.TextScreen',
78 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 89
         right: {
84 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,7 +114,7 @@ class WelcomeScreen extends Component {
105 114
 
106 115
   onClickShowModal() {
107 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,7 +6,6 @@ import PushedScreen from './PushedScreen';
6 6
 import LifecycleScreen from './LifecycleScreen';
7 7
 import ModalScreen from './ModalScreen';
8 8
 
9
-
10 9
 export function registerContainers() {
11 10
   Navigation.registerContainer(`navigation.playground.WelcomeScreen`, () => WelcomeScreen);
12 11
   Navigation.registerContainer(`navigation.playground.ModalScreen`, () => ModalScreen);