|
@@ -9,6 +9,7 @@ import com.reactnativenavigation.mocks.TestReactView;
|
9
|
9
|
import com.reactnativenavigation.parse.Options;
|
10
|
10
|
import com.reactnativenavigation.presentation.ComponentPresenter;
|
11
|
11
|
import com.reactnativenavigation.presentation.Presenter;
|
|
12
|
+import com.reactnativenavigation.views.ComponentLayout;
|
12
|
13
|
import com.reactnativenavigation.views.StackLayout;
|
13
|
14
|
|
14
|
15
|
import org.junit.Test;
|
|
@@ -22,8 +23,9 @@ import static org.mockito.Mockito.when;
|
22
|
23
|
|
23
|
24
|
public class ComponentViewControllerTest extends BaseTest {
|
24
|
25
|
private ComponentViewController uut;
|
25
|
|
- private IReactView view;
|
26
|
|
- private ComponentPresenter componentPresenter;
|
|
26
|
+ private ComponentLayout view;
|
|
27
|
+ private ComponentPresenter presenter;
|
|
28
|
+ private Options resolvedOptions = new Options();
|
27
|
29
|
|
28
|
30
|
@Override
|
29
|
31
|
public void beforeEach() {
|
|
@@ -32,12 +34,32 @@ public class ComponentViewControllerTest extends BaseTest {
|
32
|
34
|
view = spy(new TestComponentLayout(activity, new TestReactView(activity)));
|
33
|
35
|
ParentController<StackLayout> parentController = TestUtils.newStackController(activity).build();
|
34
|
36
|
Presenter presenter = new Presenter(activity, new Options());
|
35
|
|
- this.componentPresenter = spy(new ComponentPresenter());
|
36
|
|
- uut = new ComponentViewController(activity, new ChildControllersRegistry(), "componentId1", "componentName", (activity1, componentId, componentName) -> view, new Options(), presenter, this.componentPresenter);
|
|
37
|
+ this.presenter = spy(new ComponentPresenter(Options.EMPTY));
|
|
38
|
+ uut = new ComponentViewController(activity, new ChildControllersRegistry(), "componentId1", "componentName", (activity1, componentId, componentName) -> view, new Options(), presenter, this.presenter) {
|
|
39
|
+ @Override
|
|
40
|
+ public Options resolveCurrentOptions(Options defaultOptions) {
|
|
41
|
+ return resolvedOptions;
|
|
42
|
+ }
|
|
43
|
+ };
|
37
|
44
|
uut.setParentController(parentController);
|
38
|
45
|
parentController.ensureViewIsCreated();
|
39
|
46
|
}
|
40
|
47
|
|
|
48
|
+ @Test
|
|
49
|
+ public void setDefaultOptions() {
|
|
50
|
+ Options defaultOptions = new Options();
|
|
51
|
+ uut.setDefaultOptions(defaultOptions);
|
|
52
|
+ verify(presenter).setDefaultOptions(defaultOptions);
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ @Test
|
|
56
|
+ public void applyOptions() {
|
|
57
|
+ Options options = new Options();
|
|
58
|
+ uut.applyOptions(options);
|
|
59
|
+ verify(view).applyOptions(options);
|
|
60
|
+ verify(presenter).applyOptions(view, resolvedOptions);
|
|
61
|
+ }
|
|
62
|
+
|
41
|
63
|
@Test
|
42
|
64
|
public void createsViewFromComponentViewCreator() {
|
43
|
65
|
assertThat(uut.getView()).isSameAs(view);
|
|
@@ -93,6 +115,6 @@ public class ComponentViewControllerTest extends BaseTest {
|
93
|
115
|
public void mergeOptions_delegatesToPresenter() {
|
94
|
116
|
Options options = new Options();
|
95
|
117
|
uut.mergeOptions(options);
|
96
|
|
- verify(componentPresenter).mergeOptions(uut.getView(), options);
|
|
118
|
+ verify(presenter).mergeOptions(uut.getView(), options);
|
97
|
119
|
}
|
98
|
120
|
}
|