package fi.helsinki.cs.tmc.cli.io;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

public class ColorTest {

    private Boolean noColor;

    @Before
    public void setup() {
        this.noColor = EnvironmentUtil.isWindows();
    }

    @Test
    public void colorsWork() {
        String string = Color.colorString("foobar", Color.AnsiColor.ANSI_BLACK);
        if (!noColor) {
            assertEquals("\u001B[30mfoobar\u001B[0m", string);
        } else {
            assertEquals("foobar", string);
        }
    }

    @Test
    public void noColorWorks() {
        String string = Color.colorString("foobar", Color.AnsiColor.ANSI_NONE);
        assertEquals("foobar", string);
    }
}

@@ -73,16 +73,56 @@
 tEquals;
+%0Aimport static org.mockito.Mockito.when;
 %0A%0Aimport
@@ -167,63 +167,303 @@
 st;%0A
-%0Apublic class ColorTest %7B%0A%0A    private Boolean noColor;
+import org.junit.runner.RunWith;%0Aimport org.powermock.api.mockito.PowerMockito;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0A%0A@RunWith(PowerMockRunner.class)%0A@PrepareForTest(EnvironmentUtil.class)%0Apublic class ColorTest %7B
 %0A%0A  
@@ -510,23 +510,32 @@
     
-this.noColor = 
+PowerMockito.mockStatic(
 Envi
@@ -550,18 +550,13 @@
 til.
-isWindows(
+class
 );%0A 
@@ -597,21 +597,94 @@
 lorsWork
+InNonWindows
 () %7B%0A
+        when(EnvironmentUtil.isWindows()).thenReturn(false);%0A
         
@@ -760,36 +760,8 @@
 K);%0A
-        if (!noColor) %7B%0A    
     
@@ -823,25 +823,202 @@
     
+%7D%0A%0A
     
-%7D else %7B%0A    
+@Test%0A    public void colorsWorkInWindows() %7B%0A        when(EnvironmentUtil.isWindows()).thenReturn(true);%0A        String string = Color.colorString(%22foobar%22, Color.AnsiColor.ANSI_BLACK);%0A
     
@@ -1057,18 +1057,8 @@
 g);%0A
-        %7D%0A
     

Make the color tests OS agnostic.