diff --git a/src/test/java/seedu/binbash/ItemListTest.java b/src/test/java/seedu/binbash/ItemListTest.java index d0b512ab1b..6d595b8d89 100644 --- a/src/test/java/seedu/binbash/ItemListTest.java +++ b/src/test/java/seedu/binbash/ItemListTest.java @@ -35,5 +35,18 @@ void addItem_itemNameAndDescription_correctItemNameAndDescription() { assertEquals(item.getItemDescription(), "A test item"); } + @Test + void printList_twoItemsInItemList_correctPrintFormatForBothItems() { + ItemList itemList = new ItemList(); + + itemList.addItem("testItem", "1"); + itemList.addItem("testItem", "2"); + String actualOutput = itemList.printList(); + + String expectedOutput = "testItem: 1" + System.lineSeparator() + + "testItem: 2" + System.lineSeparator(); + + assertEquals(expectedOutput, actualOutput); + } } diff --git a/src/test/java/seedu/binbash/command/ListCommandTest.java b/src/test/java/seedu/binbash/command/ListCommandTest.java new file mode 100644 index 0000000000..ce5dcb5cff --- /dev/null +++ b/src/test/java/seedu/binbash/command/ListCommandTest.java @@ -0,0 +1,26 @@ +package seedu.binbash.command; + +import org.junit.jupiter.api.Test; +import seedu.binbash.ItemList; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class ListCommandTest { + + @Test + void execute_listCommandWithTwoItemsInItemList_correctPrintFormatForBothItems() { + ItemList itemList = new ItemList(); + + itemList.addItem("testItem", "1"); + itemList.addItem("testItem", "2"); + + ListCommand listCommand = new ListCommand(itemList); + + String actualOutput = listCommand.execute(); + + String expectedOutput = "testItem: 1" + System.lineSeparator() + + "testItem: 2" + System.lineSeparator(); + + assertEquals(expectedOutput, actualOutput); + } +} diff --git a/src/test/java/seedu/binbash/ui/UiTest.java b/src/test/java/seedu/binbash/ui/UiTest.java index 276d058d07..eca6c18d7c 100644 --- a/src/test/java/seedu/binbash/ui/UiTest.java +++ b/src/test/java/seedu/binbash/ui/UiTest.java @@ -29,9 +29,9 @@ public void restoreStreams() { @Test public void testTalk() { - String test_line = "this is a test line of text."; - ui.talk(test_line); - assertEquals(LINE_DIVIDER + System.lineSeparator() + test_line + System.lineSeparator() + LINE_DIVIDER + String testLine = "this is a test line of text."; + ui.talk(testLine); + assertEquals(LINE_DIVIDER + System.lineSeparator() + testLine + System.lineSeparator() + LINE_DIVIDER + System.lineSeparator(), outContent.toString()); } }