瀏覽代碼

missing case

Daniel Zlotin 7 年之前
父節點
當前提交
3b8d10ac00
共有 3 個檔案被更改,包括 46 行新增1 行删除
  1. 38
    0
      playground/e2e/app.test.android.js
  2. 1
    1
      playground/e2e/app.test.ios.js
  3. 7
    0
      src/containers/ContainerWrapper.test.js

+ 38
- 0
playground/e2e/app.test.android.js 查看文件

@@ -0,0 +1,38 @@
1
+xdescribe('app android', () => {
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
+  xit('switch to tabs with side menus', () => {
22
+    elementByLabel('Switch to tab based app with side menus').tap();
23
+    elementByLabel('Switch to tab based app with side menus').swipeRight();
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
+
36
+function elementByLabel(label) {
37
+  return element(by.label(label));
38
+}

playground/e2e/app.test.js → playground/e2e/app.test.ios.js 查看文件

@@ -1,4 +1,4 @@
1
-describe('app', () => {
1
+describe('app ios', () => {
2 2
   beforeEach((done) => {
3 3
     global.simulator.relaunchApp(done);
4 4
   });

+ 7
- 0
src/containers/ContainerWrapper.test.js 查看文件

@@ -149,6 +149,13 @@ describe('ContainerWrapper', () => {
149 149
       }
150 150
     }
151 151
 
152
+    it('onStart and onStop are optional', () => {
153
+      const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
154
+      const tree = renderer.create(<NavigationContainer id={'container1'} />);
155
+      expect(() => tree.getInstance().onStart()).not.toThrow();
156
+      expect(() => tree.getInstance().onStop()).not.toThrow();
157
+    });
158
+
152 159
     it('calls onStart on OriginalContainer', () => {
153 160
       const NavigationContainer = ContainerWrapper.wrap(containerName, MyLifecycleContainer, store);
154 161
       const tree = renderer.create(<NavigationContainer id={'container1'} />);