|
@@ -39,6 +39,7 @@ public class OptionsTest extends BaseTest {
|
39
|
39
|
private static final String BOTTOM_TABS_BADGE = "3";
|
40
|
40
|
private static final String BOTTOM_TABS_CURRENT_TAB_ID = "ComponentId";
|
41
|
41
|
private static final Number BOTTOM_TABS_CURRENT_TAB_INDEX = new Number(1);
|
|
42
|
+ private static final String EXTERNAL_CLASS_CREATOR = "com.rnn.creators.Creator.createFragment";
|
42
|
43
|
private TypefaceLoader mockLoader;
|
43
|
44
|
|
44
|
45
|
@Override
|
|
@@ -57,6 +58,7 @@ public class OptionsTest extends BaseTest {
|
57
|
58
|
JSONObject json = new JSONObject()
|
58
|
59
|
.put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
|
59
|
60
|
.put("fab", createFab())
|
|
61
|
+ .put("externalComponent", createExternalComponent())
|
60
|
62
|
.put("bottomTabs", createBottomTabs());
|
61
|
63
|
Options result = Options.parse(mockLoader, json);
|
62
|
64
|
assertResult(result);
|
|
@@ -83,6 +85,7 @@ public class OptionsTest extends BaseTest {
|
83
|
85
|
assertThat(result.fabOptions.hideOnScroll.get()).isEqualTo(FAB_HIDE_ON_SCROLL);
|
84
|
86
|
assertThat(result.fabOptions.alignVertically.get()).isEqualTo(FAB_ALIGN_VERTICALLY);
|
85
|
87
|
assertThat(result.fabOptions.alignHorizontally.get()).isEqualTo(FAB_ALIGN_HORIZONTALLY);
|
|
88
|
+ assertThat(result.externalComponent.classCreator.get()).isEqualTo(EXTERNAL_CLASS_CREATOR);
|
86
|
89
|
}
|
87
|
90
|
|
88
|
91
|
@NonNull
|
|
@@ -120,6 +123,11 @@ public class OptionsTest extends BaseTest {
|
120
|
123
|
.put("visible", FAB_VISIBLE);
|
121
|
124
|
}
|
122
|
125
|
|
|
126
|
+ private JSONObject createExternalComponent() throws JSONException {
|
|
127
|
+ return new JSONObject()
|
|
128
|
+ .put("classCreator", EXTERNAL_CLASS_CREATOR);
|
|
129
|
+ }
|
|
130
|
+
|
123
|
131
|
@NonNull
|
124
|
132
|
private JSONObject createOtherFab() throws JSONException {
|
125
|
133
|
return new JSONObject()
|
|
@@ -154,6 +162,10 @@ public class OptionsTest extends BaseTest {
|
154
|
162
|
.put("tabBadge", BOTTOM_TABS_BADGE);
|
155
|
163
|
}
|
156
|
164
|
|
|
165
|
+ private JSONObject createOtherExternalClass() {
|
|
166
|
+ return new JSONObject();
|
|
167
|
+ }
|
|
168
|
+
|
157
|
169
|
@Test
|
158
|
170
|
public void mergeDoesNotMutate() throws Exception {
|
159
|
171
|
JSONObject json1 = new JSONObject();
|
|
@@ -174,10 +186,11 @@ public class OptionsTest extends BaseTest {
|
174
|
186
|
|
175
|
187
|
@Test
|
176
|
188
|
public void mergeDefaultOptions() throws Exception {
|
177
|
|
- JSONObject json = new JSONObject();
|
178
|
|
- json.put("topBar", createTopBar(TOP_BAR_VISIBLE.get()));
|
179
|
|
- json.put("fab", createFab());
|
180
|
|
- json.put("bottomTabs", createBottomTabs());
|
|
189
|
+ JSONObject json = new JSONObject()
|
|
190
|
+ .put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
|
|
191
|
+ .put("fab", createFab())
|
|
192
|
+ .put("bottomTabs", createBottomTabs())
|
|
193
|
+ .put("externalComponent", createExternalComponent());
|
181
|
194
|
Options defaultOptions = Options.parse(mockLoader, json);
|
182
|
195
|
Options options = new Options();
|
183
|
196
|
|
|
@@ -189,7 +202,8 @@ public class OptionsTest extends BaseTest {
|
189
|
202
|
JSONObject defaultJson = new JSONObject()
|
190
|
203
|
.put("topBar", createOtherTopBar())
|
191
|
204
|
.put("fab", createOtherFab())
|
192
|
|
- .put("bottomTabs", createOtherBottomTabs());
|
|
205
|
+ .put("bottomTabs", createOtherBottomTabs())
|
|
206
|
+ .put("externalComponent", createExternalComponent());
|
193
|
207
|
Options defaultOptions = Options.parse(mockLoader, defaultJson);
|
194
|
208
|
|
195
|
209
|
JSONObject json = new JSONObject()
|