Kaynağa Gözat

add e2e test for "setTabBadge"

Ran Greenberg 7 yıl önce
ebeveyn
işleme
c7228af10f

+ 6
- 0
e2e/ScreenStyle.test.js Dosyayı Görüntüle

@@ -44,4 +44,10 @@ describe('screen style', () => {
44 44
     await element(by.id('scrollView')).swipe('down', 'fast');
45 45
     await expect(element(by.type('UINavigationBar'))).toBeVisible();
46 46
   });
47
+
48
+  it('set Tab Bar badge on a current Tab', async () => {
49
+    await elementByLabel('Switch to tab based app').tap();
50
+    await elementByLabel('Set Tab Badge').tap();
51
+    await expect(element(by.text('EnCyClOpEdIa'))).toBeVisible();
52
+  });
47 53
 });

+ 17
- 18
lib/ios/RNNNavigationOptions.m Dosyayı Görüntüle

@@ -21,7 +21,7 @@
21 21
 	self.topBarButtonColor = [navigationOptions objectForKey:@"topBarButtonColor"];
22 22
 	self.topBarTranslucent = [navigationOptions objectForKey:@"topBarTranslucent"];
23 23
 	self.setTabBadge = [navigationOptions objectForKey:@"setTabBadge"];
24
-
24
+	
25 25
 	return self;
26 26
 }
27 27
 
@@ -81,24 +81,23 @@
81 81
 		viewController.navigationController.navigationBar.tintColor = buttonColor;
82 82
 	} else {
83 83
 		viewController.navigationController.navigationBar.tintColor = nil;
84
-
85
-	if (self.setTabBadge) {
86
-		NSString *badge = [RCTConvert NSString:self.setTabBadge];
87
-		if (viewController.navigationController) {
88
-			viewController.navigationController.tabBarItem.badgeValue = badge;
89
-    } else {
90
-			viewController.tabBarItem.badgeValue = badge;
91
-	}
92
-
93
-	}
94
-	
95
-	if (self.topBarTranslucent) {
96
-		if ([self.topBarTranslucent boolValue]) {
97
-			viewController.navigationController.navigationBar.translucent = YES;
98
-		} else {
99
-			viewController.navigationController.navigationBar.translucent = NO;
84
+		
85
+		if (self.setTabBadge) {
86
+			NSString *badge = [RCTConvert NSString:self.setTabBadge];
87
+			if (viewController.navigationController) {
88
+				viewController.navigationController.tabBarItem.badgeValue = badge;
89
+			} else {
90
+				viewController.tabBarItem.badgeValue = badge;
91
+			}
92
+		}
93
+		
94
+		if (self.topBarTranslucent) {
95
+			if ([self.topBarTranslucent boolValue]) {
96
+				viewController.navigationController.navigationBar.translucent = YES;
97
+			} else {
98
+				viewController.navigationController.navigationBar.translucent = NO;
99
+			}
100 100
 		}
101
-	}
102 101
 	}
103 102
 }
104 103
 @end

+ 2
- 2
playground/src/containers/TextScreen.js Dosyayı Görüntüle

@@ -14,7 +14,7 @@ class TextScreen extends Component {
14 14
         <Text style={styles.h1}>{this.props.text || 'Text Screen'}</Text>
15 15
         {this.renderTextFromFunctionInProps()}
16 16
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
17
-        <Button title={'setTabBadge'} onPress={() => this.onButtonPress()} />
17
+        <Button title={'Set Tab Badge'} onPress={() => this.onButtonPress()} />
18 18
       </View>
19 19
     );
20 20
   }
@@ -30,7 +30,7 @@ class TextScreen extends Component {
30 30
 
31 31
   onButtonPress() {
32 32
     Navigation.setOptions(this.props.containerId, {
33
-      setTabBadge: `${_.floor(Math.random() * 10)}`
33
+      setTabBadge: `EnCyClOpEdIa`
34 34
     });
35 35
   }
36 36
 }