11package fi .helsinki .cs .tmc .cli .command ;
22
3+ import static org .mockito .Mockito .when ;
4+ import static org .powermock .api .mockito .PowerMockito .mockStatic ;
5+
36import fi .helsinki .cs .tmc .cli .Application ;
47import fi .helsinki .cs .tmc .cli .CliContext ;
8+ import fi .helsinki .cs .tmc .cli .io .EnvironmentUtil ;
59import fi .helsinki .cs .tmc .cli .io .TestIo ;
610
711import org .junit .Before ;
812import org .junit .Test ;
13+ import org .junit .runner .RunWith ;
14+ import org .powermock .core .classloader .annotations .PrepareForTest ;
15+ import org .powermock .modules .junit4 .PowerMockRunner ;
916
17+ @ RunWith (PowerMockRunner .class )
18+ @ PrepareForTest (EnvironmentUtil .class )
1019public class DocumentCommandTest {
1120
1221 private Application app ;
@@ -18,14 +27,28 @@ public void setUp() {
1827 io = new TestIo ();
1928 ctx = new CliContext (io );
2029 app = new Application (ctx );
30+
31+ mockStatic (EnvironmentUtil .class );
32+ when (EnvironmentUtil .getTerminalWidth ()).thenReturn (100 );
2133 }
2234
2335 @ Test
2436 public void run () throws InterruptedException {
37+ when (EnvironmentUtil .isWindows ()).thenReturn (false );
38+ app = new Application (ctx );
39+
40+ String [] args = {"document" , "-s" , "0" };
41+ app .run (args );
42+ io .assertContains ("Original dev team" );
43+ }
44+
45+ @ Test
46+ public void failOnWindows () throws InterruptedException {
47+ when (EnvironmentUtil .isWindows ()).thenReturn (true );
2548 app = new Application (ctx );
2649
2750 String [] args = {"document" , "-s" , "0" };
2851 app .run (args );
29- io .assertContains ("dev team " );
52+ io .assertContains ("Command document doesn't exist " );
3053 }
3154}
0 commit comments