Browse Source

Test that SideMenu visibility options are consumed after being applied

Guy Carmeli 5 years ago
parent
commit
795fa80ea9

+ 0
- 5
lib/android/app/src/main/java/com/reactnativenavigation/presentation/SideMenuPresenter.java View File

38
         mergeVisibility(options);
38
         mergeVisibility(options);
39
     }
39
     }
40
 
40
 
41
-    public void mergeChildOptions(SideMenuRootOptions options) {
42
-        mergeLockMode(options);
43
-        mergeVisibility(options);
44
-    }
45
-
46
     public void applyChildOptions(Options options) {
41
     public void applyChildOptions(Options options) {
47
         applyLockMode(options.sideMenuRootOptions);
42
         applyLockMode(options.sideMenuRootOptions);
48
         mergeVisibility(options.sideMenuRootOptions);
43
         mergeVisibility(options.sideMenuRootOptions);

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuController.java View File

95
     @Override
95
     @Override
96
     public void mergeChildOptions(Options options, ViewController child) {
96
     public void mergeChildOptions(Options options, ViewController child) {
97
         super.mergeChildOptions(options, child);
97
         super.mergeChildOptions(options, child);
98
-        presenter.mergeChildOptions(options.sideMenuRootOptions);
98
+        presenter.mergeOptions(options.sideMenuRootOptions);
99
     }
99
     }
100
 
100
 
101
     @Override
101
     @Override

+ 34
- 0
lib/android/app/src/test/java/com/reactnativenavigation/presentation/SideMenuPresenterTest.java View File

1
+package com.reactnativenavigation.presentation;
2
+
3
+import com.reactnativenavigation.BaseTest;
4
+import com.reactnativenavigation.parse.SideMenuRootOptions;
5
+import com.reactnativenavigation.parse.params.Bool;
6
+import com.reactnativenavigation.views.SideMenu;
7
+
8
+import org.junit.Test;
9
+import org.mockito.Mockito;
10
+
11
+import static org.junit.Assert.assertFalse;
12
+
13
+public class SideMenuPresenterTest extends BaseTest {
14
+    private SideMenuPresenter uut;
15
+
16
+    @Override
17
+    public void beforeEach() {
18
+        uut = new SideMenuPresenter();
19
+        SideMenu sideMenu = Mockito.mock(SideMenu.class);
20
+        uut.bindView(sideMenu);
21
+    }
22
+
23
+    @Test
24
+    public void mergeVisibility_visibilityOptionsAreConsumed() {
25
+        SideMenuRootOptions options = new SideMenuRootOptions();
26
+        options.left.visible = new Bool(true);
27
+        options.right.visible = new Bool(true);
28
+
29
+        uut.mergeOptions(options);
30
+
31
+        assertFalse(options.right.visible.hasValue());
32
+        assertFalse(options.left.visible.hasValue());
33
+    }
34
+}

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuControllerTest.java View File

165
     public void mergeChildOptions() {
165
     public void mergeChildOptions() {
166
         Options options = new Options();
166
         Options options = new Options();
167
         uut.mergeChildOptions(options, child);
167
         uut.mergeChildOptions(options, child);
168
-        verify(presenter).mergeChildOptions(options.sideMenuRootOptions);
168
+        verify(presenter).mergeOptions(options.sideMenuRootOptions);
169
     }
169
     }
170
 
170
 
171
     @Test
171
     @Test