ReviewItems extends CompactComponent<ReviewItems.Props, Void> { @VisibleForTesting @DrawableRes int getIcon(final ReviewItems.Props props) { if (props.getItemsModel().hasUniqueItem()) { return props.getCollectorIcon() == null ? R.drawable.px_review_item_default : props.getCollectorIcon(); } else { return R.drawable.px_review_item_default; } } ReviewItems(@NonNull final Props props); @Override View render(@NonNull final ViewGroup parent);  }
@Test public void whenModelHasMultipleItemsThenShowDefaultIcon() { when(itemsModel.hasUniqueItem()).thenReturn(false); final int icon = renderer.getIcon(props); assertEquals(R.drawable.px_review_item_default, icon); }
@Test public void whenIconIsAvailableInPreferenceAndIsUniqueItemThenShowIt() { when(itemsModel.hasUniqueItem()).thenReturn(true); when(props.getCollectorIcon()).thenReturn(RESOURCE_ID); final int icon = renderer.getIcon(props); assertEquals(RESOURCE_ID, icon); }
@Test public void whenIconIsNotAvailableInPreferenceThenShowDefaultIcon() { when(itemsModel.hasUniqueItem()).thenReturn(true); when(props.getCollectorIcon()).thenReturn(null); final int icon = renderer.getIcon(props); assertEquals(R.drawable.px_review_item_default, icon); }