package guitests;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

import seedu.taskboss.commons.core.Messages;
import seedu.taskboss.testutil.TestTask;

public class FindCommandTest extends TaskBossGuiTest {

    //---------------- Tests for FindCommand --------------------------------------

    /*
     * Valid equivalence partitions:
     * - task keywords (name and information)
     * - start datetime
     * - end datetime
     */

    // Equivalence partition: find by keywords in a non-empty list
    @Test
    public void find_byKeywordNonEmptyList() {
        assertFindResult("find k/Mark"); // no results
        assertFindResult("find k/Meier", td.taskD, td.taskB); // multiple results

        //find after deleting one result
        commandBox.runCommand("delete 2");
        assertFindResult("find k/Meier", td.taskD);
    }

    // EP: find by name in an empty list
    @Test
    public void find_emptyList() {
        commandBox.runCommand("clear");
        assertFindResult("find k/meeting"); // no results
    }

    // EP: find by start datetime with short command
    @Test
    public void find_usingShortCommand() {
        assertFindResult("f sd/Jul"); // no results
        assertFindResult("f sd/5:00 PM", td.taskE, td.taskA, td.taskG); // multiple results
    }

    //EP: invalid command word
    @Test
    public void find_invalidCommand_fail() {
        commandBox.runCommand("findgeorge");
        assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND);
    }

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

@@ -614,12 +614,11 @@
 d k/
-Mark
+Hey
 %22); 
@@ -656,37 +656,36 @@
 dResult(%22find k/
-Meier
+code
 %22, td.taskD, td.
@@ -678,17 +678,17 @@
  td.task
-D
+E
 , td.tas
@@ -688,17 +688,17 @@
  td.task
-B
+D
 ); // mu
@@ -834,13 +834,12 @@
 d k/
-Meier
+code
 %22, t
@@ -844,17 +844,17 @@
  td.task
-D
+E
 );%0A    %7D

update findCommandTest