瀏覽代碼

fixed tests, removed verbose logging

Daniel Zlotin 6 年之前
父節點
當前提交
099ebe9c08
共有 3 個文件被更改,包括 21 次插入9 次删除
  1. 1
    1
      lib/src/commands/OptionsProcessor.js
  2. 19
    7
      lib/src/commands/OptionsProcessor.test.js
  3. 1
    1
      scripts/test.e2e.ios.js

+ 1
- 1
lib/src/commands/OptionsProcessor.js 查看文件

11
       if (_.isEqual(key, 'icon') || _.endsWith(key, 'Icon') || _.endsWith(key, 'Image')) {
11
       if (_.isEqual(key, 'icon') || _.endsWith(key, 'Icon') || _.endsWith(key, 'Image')) {
12
         navigationOptions[key] = resolveAssetSource(navigationOptions[key]);
12
         navigationOptions[key] = resolveAssetSource(navigationOptions[key]);
13
       }
13
       }
14
-      if (_.isPlainObject(value) || _.isArray(value)) {
14
+      if (_.isObject(value) || _.isArray(value)) {
15
         OptionsProcessor.processOptions(value);
15
         OptionsProcessor.processOptions(value);
16
       }
16
       }
17
     });
17
     });

+ 19
- 7
lib/src/commands/OptionsProcessor.test.js 查看文件

1
 const OptionsProcessor = require('./OptionsProcessor');
1
 const OptionsProcessor = require('./OptionsProcessor');
2
+const NavigationOptions = require('./../params/NavigationOptions');
2
 
3
 
3
 describe('navigation options', () => {
4
 describe('navigation options', () => {
4
   let navigationOptions;
5
   let navigationOptions;
69
   });
70
   });
70
 
71
 
71
   it('any nested recursive keys ending with Color', () => {
72
   it('any nested recursive keys ending with Color', () => {
72
-    navigationOptions.innerObj = { theKeyColor: 'red' };
73
-    navigationOptions.innerObj.innerMostObj = { anotherColor: 'yellow' };
73
+    navigationOptions.topBar = { textColor: 'red' };
74
+    navigationOptions.topBar.innerMostObj = { anotherColor: 'yellow' };
74
     OptionsProcessor.processOptions(navigationOptions);
75
     OptionsProcessor.processOptions(navigationOptions);
75
-    expect(navigationOptions.innerObj.theKeyColor).toEqual(0xffff0000);
76
-    expect(navigationOptions.innerObj.innerMostObj.anotherColor).toEqual(0xffffff00);
76
+    expect(navigationOptions.topBar.textColor).toEqual(0xffff0000);
77
+    expect(navigationOptions.topBar.innerMostObj.anotherColor).toEqual(0xffffff00);
77
   });
78
   });
78
 
79
 
79
   it('resolve image sources with name/ending with icon', () => {
80
   it('resolve image sources with name/ending with icon', () => {
80
     navigationOptions.icon = 'require("https://wix.github.io/react-native-navigation/_images/logo.png");';
81
     navigationOptions.icon = 'require("https://wix.github.io/react-native-navigation/_images/logo.png");';
81
-    navigationOptions.innerObj = {
82
+    navigationOptions.topBar = {
82
       myIcon: 'require("https://wix.github.io/react-native-navigation/_images/logo.png");',
83
       myIcon: 'require("https://wix.github.io/react-native-navigation/_images/logo.png");',
83
       myOtherValue: 'value'
84
       myOtherValue: 'value'
84
     };
85
     };
88
     // I assign the icons to strings (what the require would generally look like)
89
     // I assign the icons to strings (what the require would generally look like)
89
     // and expect the value to be resovled, in this case it doesn't find anything and returns null
90
     // and expect the value to be resovled, in this case it doesn't find anything and returns null
90
     expect(navigationOptions.icon).toEqual(null);
91
     expect(navigationOptions.icon).toEqual(null);
91
-    expect(navigationOptions.innerObj.myIcon).toEqual(null);
92
-    expect(navigationOptions.innerObj.myOtherValue).toEqual('value');
92
+    expect(navigationOptions.topBar.myIcon).toEqual(null);
93
+    expect(navigationOptions.topBar.myOtherValue).toEqual('value');
94
+  });
95
+
96
+  it('processes NavigationOptions jsDoc object', () => {
97
+    navigationOptions.someKeyColor = 'rgb(255, 0, 255)';
98
+    navigationOptions.topBar = { textColor: 'red' };
99
+    navigationOptions.topBar.innerMostObj = { anotherColor: 'yellow' };
100
+    const navigationOptionsObj = new NavigationOptions(navigationOptions);
101
+
102
+    OptionsProcessor.processOptions(navigationOptionsObj);
103
+
104
+    expect(navigationOptionsObj.topBar.textColor).toEqual(0xffff0000);
93
   });
105
   });
94
 });
106
 });

+ 1
- 1
scripts/test.e2e.ios.js 查看文件

7
 
7
 
8
 function run() {
8
 function run() {
9
   const conf = release ? `release` : `debug`;
9
   const conf = release ? `release` : `debug`;
10
-  exec.execSync(`detox build --configuration ios.sim.${conf} && detox test --configuration ios.sim.${conf} ${process.env.CI ? '--cleanup' : ''} --loglevel verbose`);
10
+  exec.execSync(`detox build --configuration ios.sim.${conf} && detox test --configuration ios.sim.${conf} ${process.env.CI ? '--cleanup' : ''}`);
11
 }
11
 }
12
 
12