package guitests;

import org.junit.Test;

import seedu.taskitty.logic.ToolTip;
import seedu.taskitty.logic.commands.AddCommand;
import seedu.taskitty.logic.commands.ClearCommand;
import seedu.taskitty.logic.commands.Command;
import seedu.taskitty.logic.commands.DeleteCommand;
import seedu.taskitty.logic.commands.DoneCommand;
import seedu.taskitty.logic.commands.EditCommand;
import seedu.taskitty.logic.commands.ExitCommand;
import seedu.taskitty.logic.commands.FindCommand;
import seedu.taskitty.logic.commands.HelpCommand;
import seedu.taskitty.logic.commands.UndoCommand;
import seedu.taskitty.logic.commands.ViewCommand;

import static org.junit.Assert.assertTrue;

public class ToolTipTest extends TaskManagerGuiTest {

    @Test
    public void validInput() {
        assertToolTip("a", AddCommand.MESSAGE_USAGE);
        assertToolTip("v", ViewCommand.MESSAGE_USAGE);
        assertToolTip("f", FindCommand.MESSAGE_USAGE);
        assertToolTip("ed", EditCommand.MESSAGE_USAGE);
        assertToolTip("de", DeleteCommand.MESSAGE_USAGE);
        assertToolTip("do", DoneCommand.MESSAGE_USAGE);
        assertToolTip("u", UndoCommand.MESSAGE_USAGE);
        assertToolTip("c", ClearCommand.MESSAGE_USAGE);
        assertToolTip("h", HelpCommand.MESSAGE_USAGE);
        assertToolTip("ex", ExitCommand.MESSAGE_USAGE);
        assertToolTip("", buildToolTip());
    }
    
    private String buildToolTip() {
        return buildToolTip(Command.ALL_COMMAND_WORDS);
    }
    
    private String buildToolTip(String... expectedCommandWords) {
        StringBuilder builder = new StringBuilder();
        builder.append(expectedCommandWords[0]);
        
        for (int i = 1; i < expectedCommandWords.length; i++) {
            builder.append(ToolTip.TOOLTIP_DELIMITER + expectedCommandWords[i]);
        }
        return builder.toString();
    }

    private void assertToolTip(String input, String expectedToolTip) {
        commandBox.enterCommand(input);

        //confirm the tooltip shown is correct
        assertTrue(expectedToolTip.equals(resultDisplay.getText()));
    }

}

@@ -622,16 +622,93 @@
 mmand;%0A%0A
+import static seedu.taskitty.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND;%0A%0A
 import s
@@ -742,16 +742,16 @@
 rtTrue;%0A
-
 %0Apublic 
@@ -834,16 +834,33 @@
 lidInput
+_commandBeginning
 () %7B%0A   
@@ -1420,44 +1420,544 @@
     
-    assertToolTip(%22%22, buildToolTip()
+%7D%0A    %0A    @Test%0A    public void validInput_commandFull() %7B%0A        assertToolTip(%22add test 12 oct 3pm%22, AddCommand.MESSAGE_USAGE);%0A        assertToolTip(%22edit e 1 hello%22, EditCommand.MESSAGE_USAGE);%0A    %7D%0A    %0A    @Test%0A    public void validInput_multipleMatch() %7B%0A        assertToolTip(%22e%22, buildToolTip(%22edit%22, %22exit%22));%0A        assertToolTip(%22d%22, buildToolTip(%22delete%22, %22done%22));%0A        assertToolTip(%22%22, buildToolTip());%0A    %7D%0A    %0A    @Test%0A    public void unknownCommand() %7B%0A        assertToolTip(%22adds%22, MESSAGE_UNKNOWN_COMMAND
 );%0A 

Add more tests