Procházet zdrojové kódy

simplifying for now

Daniel Zlotin před 8 roky
rodič
revize
a546186e63
2 změnil soubory, kde provedl 15 přidání a 59 odebrání
  1. 2
    16
      src/commands/Commands.js
  2. 13
    43
      src/commands/Commands.test.js

+ 2
- 16
src/commands/Commands.js Zobrazit soubor

@@ -4,7 +4,8 @@ const {NativeNavigation} = NativeModules;
4 4
 import {uniqueId} from '../providers/UniqueIdProvider';
5 5
 
6 6
 export function startApp(params) {
7
-  NativeNavigation.startApp();
7
+  params.container.id = uniqueId(`container`);
8
+  NativeNavigation.startApp(params);
8 9
 }
9 10
 //
10 11
 //function parseParams(params) {
@@ -32,18 +33,3 @@ export function startApp(params) {
32 33
 //
33 34
 //}
34 35
 
35
-export function parse(params) {
36
-  return {
37
-    containerStack: {
38
-      id: uniqueId(`containerStack`),
39
-      stack: [
40
-        {
41
-          container: {
42
-            id: uniqueId(`container`),
43
-            key: params.container.key
44
-          }
45
-        }
46
-      ]
47
-    }
48
-  };
49
-}

+ 13
- 43
src/commands/Commands.test.js Zobrazit soubor

@@ -17,55 +17,25 @@ describe('Commands', () => {
17 17
     it('sends startApp to native', () => {
18 18
       uut.startApp({
19 19
         container: {
20
-          key: 'example.MyContainer'
20
+          key: 'com.example.MyScreen'
21 21
         }
22 22
       });
23 23
       expect(mockNativeNavigation.startApp).toHaveBeenCalledTimes(1);
24 24
     });
25 25
 
26
-    it('parses the params and construct single screen hirarchy', () => {
26
+    it('adds uniqueId to passed container', () => {
27 27
       mockUniqueIdProvider.uniqueId = jest.fn((prefix) => `${prefix}123`);
28
-
29
-      expect(uut.parse(
30
-        {
31
-          container: {
32
-            key: 'com.example.MyScreen'
33
-          }
34
-        })).toEqual(
35
-        {
36
-          containerStack: {
37
-            id: 'containerStack123',
38
-            stack: [
39
-              {
40
-                container: {
41
-                  key: 'com.example.MyScreen',
42
-                  id: 'container123'
43
-                }
44
-              }
45
-            ]
46
-          }
47
-        });
28
+      uut.startApp({
29
+        container: {
30
+          key: 'com.example.MyScreen'
31
+        }
32
+      });
33
+      expect(mockNativeNavigation.startApp).toHaveBeenCalledWith({
34
+        container: {
35
+          key: 'com.example.MyScreen',
36
+          id: 'container123'
37
+        }
38
+      });
48 39
     });
49
-    //it('receives params object', () => {
50
-    //  uut.startApp({
51
-    //    container: {
52
-    //      key: 'example.MyContainer'
53
-    //    },
54
-    //    drawer: {
55
-    //      left: {
56
-    //        key: 'example.SideMenu'
57
-    //      }
58
-    //    }
59
-    //  });
60
-    //});
61
-    //it('expects to get containerKey, or tabs with containerKeys', () => {
62
-    //  expect(() => uut.startApp({containerKey: 'example.MyContainer'})).not.toThrow();
63
-    //  expect(() => uut.startApp({tabs: [{containerKey: 'example.Tab1'}]})).not.toThrow();
64
-    //  expect(() => uut.startApp()).toThrow();
65
-    //  expect(() => uut.startApp({})).toThrow();
66
-    //  expect(() => uut.startApp({tabs: []})).toThrow();
67
-    //  expect(() => uut.startApp({tabs: [{}]})).toThrow();
68
-    //  expect(() => uut.startApp({tabs: [{containerKey: 'example.Tab1'}, {}]})).toThrow();
69
-    //});
70 40
   });
71 41
 });