|
@@ -8,6 +8,8 @@ import com.reactnativenavigation.mocks.SimpleViewController;
|
8
|
8
|
import com.reactnativenavigation.parse.Options;
|
9
|
9
|
import com.reactnativenavigation.parse.params.Bool;
|
10
|
10
|
import com.reactnativenavigation.parse.params.Colour;
|
|
11
|
+import com.reactnativenavigation.parse.params.Number;
|
|
12
|
+import com.reactnativenavigation.parse.params.Text;
|
11
|
13
|
import com.reactnativenavigation.presentation.BottomTabsPresenter;
|
12
|
14
|
import com.reactnativenavigation.viewcontrollers.bottomtabs.TabSelector;
|
13
|
15
|
import com.reactnativenavigation.views.BottomTabs;
|
|
@@ -20,6 +22,7 @@ import java.util.List;
|
20
|
22
|
|
21
|
23
|
import static org.assertj.core.api.Java6Assertions.assertThat;
|
22
|
24
|
import static org.mockito.ArgumentMatchers.any;
|
|
25
|
+import static org.mockito.Mockito.mock;
|
23
|
26
|
import static org.mockito.Mockito.spy;
|
24
|
27
|
import static org.mockito.Mockito.times;
|
25
|
28
|
import static org.mockito.Mockito.verify;
|
|
@@ -30,6 +33,7 @@ public class BottomTabsPresenterTest extends BaseTest {
|
30
|
33
|
private BottomTabsPresenter uut;
|
31
|
34
|
private BottomTabs bottomTabs;
|
32
|
35
|
private BottomTabsAnimator animator;
|
|
36
|
+ private TabSelector tabSelector;
|
33
|
37
|
|
34
|
38
|
@Override
|
35
|
39
|
public void beforeEach() {
|
|
@@ -41,7 +45,8 @@ public class BottomTabsPresenterTest extends BaseTest {
|
41
|
45
|
uut = new BottomTabsPresenter(tabs, new Options());
|
42
|
46
|
bottomTabs = Mockito.mock(BottomTabs.class);
|
43
|
47
|
animator = spy(new BottomTabsAnimator(bottomTabs));
|
44
|
|
- uut.bindView(bottomTabs, Mockito.mock(TabSelector.class), animator);
|
|
48
|
+ tabSelector = mock(TabSelector.class);
|
|
49
|
+ uut.bindView(bottomTabs, tabSelector, animator);
|
45
|
50
|
}
|
46
|
51
|
|
47
|
52
|
@Test
|
|
@@ -71,4 +76,30 @@ public class BottomTabsPresenterTest extends BaseTest {
|
71
|
76
|
uut.mergeChildOptions(options, tabs.get(0));
|
72
|
77
|
verify(animator).hide(any());
|
73
|
78
|
}
|
|
79
|
+
|
|
80
|
+ @Test
|
|
81
|
+ public void applyChildOptions_currentTabIndexIsConsumedAfterApply() {
|
|
82
|
+ Options defaultOptions = new Options();
|
|
83
|
+ defaultOptions.bottomTabsOptions.currentTabIndex = new Number(1);
|
|
84
|
+ uut.setDefaultOptions(defaultOptions);
|
|
85
|
+
|
|
86
|
+ uut.applyChildOptions(Options.EMPTY, tabs.get(0));
|
|
87
|
+ verify(tabSelector).selectTab(1);
|
|
88
|
+
|
|
89
|
+ uut.applyChildOptions(Options.EMPTY, tabs.get(0));
|
|
90
|
+ verifyNoMoreInteractions(tabSelector);
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ @Test
|
|
94
|
+ public void applyChildOptions_currentTabIdIsConsumedAfterApply() {
|
|
95
|
+ Options defaultOptions = new Options();
|
|
96
|
+ defaultOptions.bottomTabsOptions.currentTabId = new Text(tabs.get(1).getId());
|
|
97
|
+ uut.setDefaultOptions(defaultOptions);
|
|
98
|
+
|
|
99
|
+ uut.applyChildOptions(Options.EMPTY, tabs.get(0));
|
|
100
|
+ verify(tabSelector).selectTab(1);
|
|
101
|
+
|
|
102
|
+ uut.applyChildOptions(Options.EMPTY, tabs.get(0));
|
|
103
|
+ verifyNoMoreInteractions(tabSelector);
|
|
104
|
+ }
|
74
|
105
|
}
|