|
@@ -0,0 +1,47 @@
|
|
1
|
+package com.reactnativenavigation.viewcontrollers;
|
|
2
|
+
|
|
3
|
+import com.reactnativenavigation.BaseTest;
|
|
4
|
+
|
|
5
|
+import org.junit.Test;
|
|
6
|
+
|
|
7
|
+import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
8
|
+
|
|
9
|
+public class NavigationControllerTest extends BaseTest {
|
|
10
|
+
|
|
11
|
+ @Test
|
|
12
|
+ public void isAViewController() throws Exception {
|
|
13
|
+ assertThat(new NavigationController()).isInstanceOf(ViewController.class);
|
|
14
|
+ }
|
|
15
|
+
|
|
16
|
+ @Test
|
|
17
|
+ public void holdsAStackOfViewControllers() throws Exception {
|
|
18
|
+ assertThat(new NavigationController().getChildControllers()).isEmpty();
|
|
19
|
+ ViewController c1 = new ViewController();
|
|
20
|
+ ViewController c2 = new ViewController();
|
|
21
|
+ ViewController c3 = new ViewController();
|
|
22
|
+ assertThat(new NavigationController(c1, c2, c3).getChildControllers()).containsExactly(c1, c2, c3);
|
|
23
|
+ }
|
|
24
|
+
|
|
25
|
+ @Test
|
|
26
|
+ public void push() throws Exception {
|
|
27
|
+ NavigationController uut = new NavigationController();
|
|
28
|
+ ViewController c1 = new ViewController();
|
|
29
|
+ assertThat(uut.getChildControllers()).isEmpty();
|
|
30
|
+ uut.push(c1);
|
|
31
|
+ assertThat(uut.getChildControllers()).containsExactly(c1);
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ @Test
|
|
35
|
+ public void pop() throws Exception {
|
|
36
|
+ NavigationController uut = new NavigationController();
|
|
37
|
+ ViewController c1 = new ViewController();
|
|
38
|
+ ViewController c2 = new ViewController();
|
|
39
|
+ uut.push(c1);
|
|
40
|
+ uut.push(c2);
|
|
41
|
+ assertThat(uut.getChildControllers()).containsExactly(c1, c2);
|
|
42
|
+ uut.pop();
|
|
43
|
+ assertThat(uut.getChildControllers()).containsExactly(c1);
|
|
44
|
+ uut.pop();
|
|
45
|
+ assertThat(uut.getChildControllers()).isEmpty();
|
|
46
|
+ }
|
|
47
|
+}
|