package guitests;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class ClearCommandTest extends TaskBossGuiTest {

    @Test
    public void clear() {

        //verify a non-empty list can be cleared
        assertTrue(taskListPanel.isListMatching(td.getTypicalTasks()));
        assertClearCommandSuccess(false);

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

        //verify the short clear command can work
        commandBox.runCommand(td.kelvin.getShortAddCommand());
        assertListSize(1);
        assertClearCommandSuccess(true);

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

    private void assertClearCommandSuccess(boolean isShortCommand) {
        if (isShortCommand) {
            commandBox.runCommand("c");
        } else {
            commandBox.runCommand("clear");
        }
        assertListSize(0);
        assertResultMessage("TaskBoss has been cleared!");
    }
}

@@ -434,20 +434,21 @@
 mand(td.
-hoon
+taskH
 .getAddC
@@ -513,12 +513,13 @@
 (td.
-hoon
+taskH
 ));%0A
@@ -676,14 +676,13 @@
 (td.
-kelvin
+taskK
 .get

update clear command