package guitests;

import org.junit.Test;

import seedu.oneline.logic.commands.ClearCommand;
import seedu.oneline.testutil.TestTask;
import seedu.oneline.testutil.TypicalTestTasks;

import static org.junit.Assert.assertTrue;

import java.util.Arrays;

public class ClearCommandTest extends TaskBookGuiTest {

    @Test
    public void clear() {

        //verify a non-empty list can be cleared
        TestTask[] ts = td.getTypicalTasks();
        Arrays.sort(ts);
        assertTrue(taskPane.isListMatching(ts));
        assertClearCommandSuccess();

        //verify other commands can work after a clear command
        commandBox.runCommand(td.todo1.getAddCommand());
        assertTrue(taskPane.isListMatching(td.todo1));
        commandBox.runCommand("del 1");
        assertListSize(0);

        //verify clear command works when the list is empty
        assertClearCommandSuccess();
    }

    private void assertClearCommandSuccess() {
        commandBox.runCommand("clear");
        assertListSize(0);
        assertResultMessage(ClearCommand.MESSAGE_SUCCESS);
    }
}

@@ -337,62 +337,38 @@
 lear
-() %7B%0A%0A        //verify a non-empty list can be cleared
+Command_clearTasks_success() %7B
 %0A   
@@ -525,71 +525,120 @@
 ();%0A
+    %7D
 %0A    
+%0A
     
-//verify other commands can work after a c
+@Test%0A    public void clearCommand_addAfterClear_success() %7B%0A        assertC
 lear
- c
+C
 ommand
+Success();
 %0A   
@@ -664,18 +664,32 @@
 Command(
-td
+TypicalTestTasks
 .todo1.g
@@ -748,18 +748,32 @@
 atching(
-td
+TypicalTestTasks
 .todo1))
@@ -845,68 +845,84 @@
 0);%0A
+    %7D
 %0A    
+%0A 
    
- //verify
+@Test%0A    public void
  clear
- c
+C
 ommand
- works when the list is empty
+_clearEmptyList_success() %7B
 %0A   

Refactor ClearCommandTest