|  | @@ -16,6 +16,7 @@ import com.reactnativenavigation.layout.bottomtabs.BottomTabsCreator;
 | 
	
		
			
			| 16 | 16 |  import org.junit.Before;
 | 
	
		
			
			| 17 | 17 |  import org.junit.Test;
 | 
	
		
			
			| 18 | 18 |  import org.junit.runner.RunWith;
 | 
	
		
			
			|  | 19 | +import org.mockito.ArgumentCaptor;
 | 
	
		
			
			| 19 | 20 |  import org.robolectric.Robolectric;
 | 
	
		
			
			| 20 | 21 |  import org.robolectric.RobolectricTestRunner;
 | 
	
		
			
			| 21 | 22 |  
 | 
	
	
		
			
			|  | @@ -27,7 +28,6 @@ import java.util.List;
 | 
	
		
			
			| 27 | 28 |  
 | 
	
		
			
			| 28 | 29 |  import static org.assertj.core.api.Java6Assertions.assertThat;
 | 
	
		
			
			| 29 | 30 |  import static org.mockito.ArgumentMatchers.any;
 | 
	
		
			
			| 30 |  | -import static org.mockito.ArgumentMatchers.anyString;
 | 
	
		
			
			| 31 | 31 |  import static org.mockito.ArgumentMatchers.eq;
 | 
	
		
			
			| 32 | 32 |  import static org.mockito.Mockito.mock;
 | 
	
		
			
			| 33 | 33 |  import static org.mockito.Mockito.verify;
 | 
	
	
		
			
			|  | @@ -44,12 +44,14 @@ public class LayoutFactoryTest {
 | 
	
		
			
			| 44 | 44 |  
 | 
	
		
			
			| 45 | 45 |      private Activity activity;
 | 
	
		
			
			| 46 | 46 |      private View mockView;
 | 
	
		
			
			|  | 47 | +    private View otherMockView;
 | 
	
		
			
			| 47 | 48 |      private LayoutFactory.RootViewCreator rootViewCreator;
 | 
	
		
			
			| 48 | 49 |  
 | 
	
		
			
			| 49 | 50 |      @Before
 | 
	
		
			
			| 50 | 51 |      public void setUp() {
 | 
	
		
			
			| 51 | 52 |          activity = Robolectric.buildActivity(AppCompatActivity.class).get();
 | 
	
		
			
			| 52 | 53 |          mockView = new View(activity);
 | 
	
		
			
			|  | 54 | +        otherMockView = new View(activity);
 | 
	
		
			
			| 53 | 55 |          rootViewCreator = mock(LayoutFactory.RootViewCreator.class);
 | 
	
		
			
			| 54 | 56 |      }
 | 
	
		
			
			| 55 | 57 |  
 | 
	
	
		
			
			|  | @@ -68,7 +70,7 @@ public class LayoutFactoryTest {
 | 
	
		
			
			| 68 | 70 |      public void returnsContainerStack() throws Exception {
 | 
	
		
			
			| 69 | 71 |          when(rootViewCreator.createRootView(eq(VIEW_ID), eq(VIEW_NAME))).thenReturn(mockView);
 | 
	
		
			
			| 70 | 72 |          final LayoutNode containerNode = createContainerNode();
 | 
	
		
			
			| 71 |  | -        final LayoutNode stackNode = getContainerStackNode(containerNode);
 | 
	
		
			
			|  | 73 | +        final LayoutNode stackNode = createContainerStackNode(containerNode);
 | 
	
		
			
			| 72 | 74 |  
 | 
	
		
			
			| 73 | 75 |          final ViewGroup result = (ViewGroup) createLayoutFactory().create(stackNode);
 | 
	
		
			
			| 74 | 76 |  
 | 
	
	
		
			
			|  | @@ -86,7 +88,7 @@ public class LayoutFactoryTest {
 | 
	
		
			
			| 86 | 88 |  
 | 
	
		
			
			| 87 | 89 |          final LayoutNode containerNode1 = createContainerNode(VIEW_ID, VIEW_NAME);
 | 
	
		
			
			| 88 | 90 |          final LayoutNode containerNode2 = createContainerNode(OTHER_VIEW_ID, OTHER_VIEW_NAME);
 | 
	
		
			
			| 89 |  | -        final LayoutNode stackNode = getContainerStackNode(Arrays.asList(containerNode1, containerNode2));
 | 
	
		
			
			|  | 91 | +        final LayoutNode stackNode = createContainerStackNode(containerNode1, containerNode2);
 | 
	
		
			
			| 90 | 92 |  
 | 
	
		
			
			| 91 | 93 |          final ViewGroup result = (ViewGroup) createLayoutFactory().create(stackNode);
 | 
	
		
			
			| 92 | 94 |  
 | 
	
	
		
			
			|  | @@ -101,14 +103,41 @@ public class LayoutFactoryTest {
 | 
	
		
			
			| 101 | 103 |      @Test
 | 
	
		
			
			| 102 | 104 |      public void returnsSingleTabContent() throws Exception {
 | 
	
		
			
			| 103 | 105 |          BottomTabs bottomTabsMock = mock(BottomTabs.class);
 | 
	
		
			
			|  | 106 | +        when(bottomTabsMock.getTabsCount()).thenReturn(0);
 | 
	
		
			
			|  | 107 | +
 | 
	
		
			
			| 104 | 108 |          when(rootViewCreator.createRootView(eq(VIEW_ID), eq(VIEW_NAME))).thenReturn(mockView);
 | 
	
		
			
			| 105 | 109 |          final LayoutNode containerNode = createContainerNode();
 | 
	
		
			
			| 106 | 110 |          final LayoutNode tabNode = createTabNode(containerNode);
 | 
	
		
			
			| 107 | 111 |  
 | 
	
		
			
			| 108 | 112 |          final View result = createLayoutFactory(bottomTabsMock).create(tabNode);
 | 
	
		
			
			| 109 | 113 |  
 | 
	
		
			
			|  | 114 | +        assertThat(result).isInstanceOf(BottomTabsContainer.class);
 | 
	
		
			
			|  | 115 | +
 | 
	
		
			
			|  | 116 | +        ArgumentCaptor<Container> containerCaptor = ArgumentCaptor.forClass(Container.class);
 | 
	
		
			
			|  | 117 | +        verify(bottomTabsMock).addTab(eq("#0"), containerCaptor.capture());
 | 
	
		
			
			|  | 118 | +        Container container = containerCaptor.getValue();
 | 
	
		
			
			|  | 119 | +        View view = assertViewChildrenCount(container, 1).get(0);
 | 
	
		
			
			|  | 120 | +        assertThat(view).isEqualTo(mockView);
 | 
	
		
			
			|  | 121 | +    }
 | 
	
		
			
			|  | 122 | +
 | 
	
		
			
			|  | 123 | +    @Test
 | 
	
		
			
			|  | 124 | +    public void returnsTwoTabContent() throws Exception {
 | 
	
		
			
			|  | 125 | +        BottomTabs bottomTabsMock = mock(BottomTabs.class);
 | 
	
		
			
			|  | 126 | +        when(bottomTabsMock.getTabsCount()).thenReturn(0, 1);
 | 
	
		
			
			|  | 127 | +
 | 
	
		
			
			|  | 128 | +        when(rootViewCreator.createRootView(eq(VIEW_ID), eq(VIEW_NAME))).thenReturn(mockView);
 | 
	
		
			
			|  | 129 | +        final LayoutNode firstTabRootNode = createContainerNode(VIEW_ID, VIEW_NAME);
 | 
	
		
			
			|  | 130 | +
 | 
	
		
			
			|  | 131 | +        when(rootViewCreator.createRootView(eq(OTHER_VIEW_ID), eq(OTHER_VIEW_NAME))).thenReturn(otherMockView);
 | 
	
		
			
			|  | 132 | +        final LayoutNode secondTabRootNode = createContainerStackNode(createContainerNode(OTHER_VIEW_ID, OTHER_VIEW_NAME));
 | 
	
		
			
			|  | 133 | +
 | 
	
		
			
			|  | 134 | +        final LayoutNode tabNode = createTabNode(firstTabRootNode, secondTabRootNode);
 | 
	
		
			
			|  | 135 | +
 | 
	
		
			
			|  | 136 | +        final View result = createLayoutFactory(bottomTabsMock).create(tabNode);
 | 
	
		
			
			|  | 137 | +
 | 
	
		
			
			| 110 | 138 |          assertThat(result).isInstanceOf(BottomTabsContainer.class);
 | 
	
		
			
			| 111 | 139 |          verify(bottomTabsMock).addTab(eq("#0"), any(Container.class));
 | 
	
		
			
			|  | 140 | +        verify(bottomTabsMock).addTab(eq("#1"), any(ContainerStack.class));
 | 
	
		
			
			| 112 | 141 |      }
 | 
	
		
			
			| 113 | 142 |  
 | 
	
		
			
			| 114 | 143 |      @Test(expected = IllegalArgumentException.class)
 | 
	
	
		
			
			|  | @@ -141,18 +170,14 @@ public class LayoutFactoryTest {
 | 
	
		
			
			| 141 | 170 |          return new LayoutNode(id, "Container", new HashMap<String, Object>() {{ put("name", name); }});
 | 
	
		
			
			| 142 | 171 |      }
 | 
	
		
			
			| 143 | 172 |  
 | 
	
		
			
			| 144 |  | -    private LayoutNode getContainerStackNode(LayoutNode innerNode) {
 | 
	
		
			
			| 145 |  | -        return getContainerStackNode(Arrays.asList(innerNode));
 | 
	
		
			
			| 146 |  | -    }
 | 
	
		
			
			| 147 |  | -
 | 
	
		
			
			| 148 |  | -    private LayoutNode getContainerStackNode(List<LayoutNode> children) {
 | 
	
		
			
			|  | 173 | +    private LayoutNode createContainerStackNode(LayoutNode... children) {
 | 
	
		
			
			| 149 | 174 |          LayoutNode node = new LayoutNode();
 | 
	
		
			
			| 150 | 175 |          node.type = "ContainerStack";
 | 
	
		
			
			| 151 |  | -        node.children = children;
 | 
	
		
			
			|  | 176 | +        node.children = Arrays.asList(children);
 | 
	
		
			
			| 152 | 177 |          return node;
 | 
	
		
			
			| 153 | 178 |      }
 | 
	
		
			
			| 154 | 179 |  
 | 
	
		
			
			| 155 |  | -    private LayoutNode createTabNode(LayoutNode children) {
 | 
	
		
			
			|  | 180 | +    private LayoutNode createTabNode(LayoutNode... children) {
 | 
	
		
			
			| 156 | 181 |          LayoutNode node = new LayoutNode();
 | 
	
		
			
			| 157 | 182 |          node.type = "BottomTabs";
 | 
	
		
			
			| 158 | 183 |          node.children = Arrays.asList(children);
 |