package guitests;

import static org.junit.Assert.assertTrue;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import org.junit.Test;

import seedu.address.commons.core.Messages;
import seedu.address.logic.commands.FindCommand;
import seedu.address.testutil.TestTask;

public class FindCommandTest extends TaskManagerGuiTest {

    @Test
    public void find_nonEmptyList() {
        assertFindResult("find 38"); // no results
        assertFindResult("find 3", td.task3); // multiple results

        //find after deleting one result
        commandBox.runCommand("delete 1");
        assertFindResult("find 3");
    }

    @Test
    public void find_nonEmptyListLabel() {
        assertFindResult("find owesMoney", td.task2); // find only 1 label
    }

    @Test
    public void find_nonEmptyListMultipleLabel() {
        assertFindResult("find owesMoney friends", td.task1, td.task2); //find 2 label
    }

    @Test
    public void find_nonEmptyListStartEndDate_singleResult() {
        assertFindResult("find from today to 11-11-2017 0000", td.task6); // 1 result
    }

    @Test
    public void find_nonEmptyListStartEndDate_pass() {
        assertFindResult("find from today to christmas",
                td.task1, td.task2, td.task3, td.task4, td.task5, td.task6, td.task7); // 7 result
    }

    @Test
    public void find_emptyList() {
        commandBox.runCommand("clear");
        assertFindResult("find task 1"); // no results
    }

    @Test
    public void find_invalidCommand_fail() {
        commandBox.runCommand("findsomething");
        assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND);
    }

    @Test
    public void find_validCommandNoInput_fail() {
        commandBox.runCommand("find"); // no input here
        assertResultMessage(String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE));
    }

    private void assertFindResult(String command, TestTask... expectedHits) {
        commandBox.runCommand(command);
        assertListSize(expectedHits.length);
        assertResultMessage(expectedHits.length + " tasks listed!");
        assertTrue(taskListPanel.isListMatching(expectedHits));
    }
}

@@ -1007,24 +1007,99 @@
 eResult() %7B%0A
+        assertFindResult(%22find by 10-11-2017 2359%22, td.task6); // 1 result%0A
         asse
@@ -1392,32 +1392,177 @@
 7); // 7 result%0A
+        assertFindResult(%22find by christmas%22,%0A                td.task1, td.task2, td.task3, td.task4, td.task5, td.task6, td.task7); // 7 result%0A
     %7D%0A%0A    @Test
@@ -1864,32 +1864,245 @@
 OMMAND);%0A    %7D%0A%0A
+    @Test%0A    public void find_invalidDate_fail() %7B%0A        commandBox.runCommand(%22find by from to %22);%0A        assertResultMessage(String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE));%0A    %7D%0A%0A
     @Test%0A    pu

Add more test cases in find command test