Ran Greenberg 7 years ago
parent
commit
1b49d0a186
2 changed files with 210 additions and 0 deletions
  1. 62
    0
      playground/e2e/app.test.js.orig
  2. 148
    0
      playground/src/containers/WelcomeScreen.js.orig

+ 62
- 0
playground/e2e/app.test.js.orig View File

@@ -0,0 +1,62 @@
1
+describe('app', () => {
2
+  beforeEach((done) => {
3
+    global.simulator.relaunchApp(done);
4
+  });
5
+
6
+  it('shows welcome screen', () => {
7
+    expect(elementByLabel('React Native Navigation!')).toBeVisible();
8
+  });
9
+
10
+  it('switch to tab based app, passProps and functions', () => {
11
+    elementByLabel('Switch to tab based app').tap();
12
+    expect(elementByLabel('This is tab 1')).toBeVisible();
13
+    expect(elementByLabel('Hello from a function!')).toBeVisible();
14
+  });
15
+
16
+  it('push screen', () => {
17
+    elementByLabel('Push').tap();
18
+    expect(elementByLabel('Pushed screen')).toBeVisible();
19
+  });
20
+
21
+  it('switch to tabs with side menus', () => {
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();
25
+  });
26
+
27
+  it('screen lifecycle', () => {
28
+    elementByLabel('Switch to lifecycle screen').tap();
29
+    expect(elementByLabel('onStart!')).toBeVisible();
30
+    elementByLabel('Push to test onStop').tap();
31
+    expect(elementByLabel('Alert')).toBeVisible();
32
+    expect(elementByLabel('onStop!')).toBeVisible();
33
+  });
34
+
35
+  it('pop screen', () => {
36
+    elementByLabel('Push').tap();
37
+    expect(elementByLabel('Pushed screen')).toBeVisible();
38
+    elementByLabel('Pop').tap();
39
+    expect(elementByLabel('React Native Navigation!')).toBeVisible();
40
+  });
41
+<<<<<<< HEAD
42
+  
43
+});
44
+
45
+describe('reload app', () => {
46
+  before(function (done) {
47
+    simulator.reloadReactNativeApp(done);
48
+  });
49
+  it('shows welcome screen', () => {
50
+    expect(elementByLabel('React Native Navigation!')).toBeVisible();
51
+=======
52
+
53
+  xit('show modal', () => {
54
+    elementByLabel('Show Modal').tap();
55
+    expect(elementByLabel('Modal screen')).toBeVisible();
56
+>>>>>>> 886672b24c98bd44fe235b9f4a5084da85b45d8d
57
+  });
58
+});
59
+
60
+function elementByLabel(label) {
61
+  return element(by.label(label));
62
+}

+ 148
- 0
playground/src/containers/WelcomeScreen.js.orig View File

@@ -0,0 +1,148 @@
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 WelcomeScreen extends Component {
7
+  constructor(props) {
8
+    super(props);
9
+    this.onClickPush = this.onClickPush.bind(this);
10
+    this.onShowModal = this.onShowModal.bind(this);
11
+  }
12
+
13
+  render() {
14
+    return (
15
+      <View style={styles.root}>
16
+        <Text style={styles.h1}>{`React Native Navigation!`}</Text>
17
+        <Button title="Switch to tab based app" onPress={this.onClickSwitchToTabs} />
18
+        <Button title="Switch to app with side menus" onPress={this.onClickSwitchToSideMenus} />
19
+        <Button title="Switch to lifecycle screen" onPress={this.onClickLifecycleScreen} />
20
+        <Button title="Push" onPress={this.onClickPush} />
21
+<<<<<<< HEAD
22
+        <Button title="Show Modal" onPress={this.onClickPush} />
23
+=======
24
+        <Button title="Show Modal" onPress={this.onClickShowModal} />
25
+>>>>>>> 886672b24c98bd44fe235b9f4a5084da85b45d8d
26
+        <Text style={styles.footer}>{`this.props.id = ${this.props.id}`}</Text>
27
+      </View>
28
+    );
29
+  }
30
+
31
+  onClickSwitchToTabs() {
32
+    Navigation.setRoot({
33
+      tabs: [
34
+        {
35
+          container: {
36
+            name: 'navigation.playground.SimpleScreen',
37
+            passProps: {
38
+              text: 'This is tab 1',
39
+              myFunction: () => 'Hello from a function!'
40
+            }
41
+          }
42
+        },
43
+        {
44
+          container: {
45
+            name: 'navigation.playground.SimpleScreen',
46
+            passProps: {
47
+              text: 'This is tab 2'
48
+            }
49
+          }
50
+        }
51
+      ]
52
+    });
53
+  }
54
+
55
+  onClickSwitchToSideMenus() {
56
+    Navigation.setRoot({
57
+      tabs: [
58
+        {
59
+          container: {
60
+            name: 'navigation.playground.SimpleScreen',
61
+            passProps: {
62
+              text: 'This is a side menu center screen'
63
+            }
64
+          }
65
+        },
66
+        {
67
+          container: {
68
+            name: 'navigation.playground.SimpleScreen'
69
+          }
70
+        },
71
+        {
72
+          container: {
73
+            name: 'navigation.playground.SimpleScreen'
74
+          }
75
+        }
76
+      ],
77
+      sideMenu: {
78
+        left: {
79
+          container: {
80
+            name: 'navigation.playground.SimpleScreen',
81
+            passProps: {
82
+              text: 'This is a side menu screen'
83
+            }
84
+          }
85
+        },
86
+        right: {
87
+          container: {
88
+            name: 'navigation.playground.SimpleScreen'
89
+          }
90
+        }
91
+      }
92
+    });
93
+  }
94
+
95
+  onClickPush() {
96
+    Navigation.on(this.props.id).push({
97
+      name: 'navigation.playground.SimpleScreen',
98
+      passProps: {
99
+        text: 'Pushed screen',
100
+        stackPosition: 1
101
+      }
102
+    });
103
+  }
104
+
105
+  onClickLifecycleScreen() {
106
+    Navigation.setRoot({
107
+      container: {
108
+        name: 'navigation.playground.LifecycleScreen'
109
+      }
110
+    });
111
+  }
112
+<<<<<<< HEAD
113
+  
114
+  onShowModal() {
115
+    Navigation.on(this.props.id).show
116
+=======
117
+
118
+  onClickShowModal() {
119
+    Navigation.showModal({
120
+      name: 'navigation.playground.SimpleScreen',
121
+      passProps: {
122
+        text: 'Modal screen'
123
+      }
124
+    });
125
+>>>>>>> 886672b24c98bd44fe235b9f4a5084da85b45d8d
126
+  }
127
+}
128
+
129
+export default WelcomeScreen;
130
+
131
+const styles = {
132
+  root: {
133
+    flexGrow: 1,
134
+    justifyContent: 'center',
135
+    alignItems: 'center',
136
+    backgroundColor: '#f5fcff'
137
+  },
138
+  h1: {
139
+    fontSize: 24,
140
+    textAlign: 'center',
141
+    margin: 30
142
+  },
143
+  footer: {
144
+    fontSize: 10,
145
+    color: '#888',
146
+    marginTop: 80
147
+  }
148
+};