package guitests;

import org.junit.Test;

import tars.commons.core.Messages;
import tars.testutil.TestTask;

import static org.junit.Assert.assertTrue;

public class FindCommandTest extends TarsGuiTest {

    @Test
    public void find_nonEmptyList() {
        assertFindResult("find Mark"); //no results
        assertFindResult("find Meier", td.taskB, td.taskD); //multiple results

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

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

    @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));
    }
}

@@ -283,11 +283,14 @@
 nd M
-ark
+eeting
 %22); 
@@ -337,34 +337,150 @@
 ind 
-Meier%22, td.taskB, td.taskD
+Task B%22, %0A                td.taskA, td.taskB,%0A                td.taskC, td.taskD,%0A                td.taskE, td.taskF,%0A                td.taskG
 ); /
@@ -617,23 +617,10 @@
 ind 
-Meier%22,td.taskD
+A%22
 );%0A 
@@ -744,12 +744,20 @@
 ind 
-Jean
+No Such Task
 %22); 
@@ -870,14 +870,15 @@
 find
-george
+meeting
 %22);%0A

Update test cases in FindCommandTest.java