Skip to content

Commit

Permalink
Update JUnit test expected output
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaniceTang committed Nov 13, 2023
1 parent fbdfc4c commit 9032698
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ void execute_validInput_returnCorrectOutput() {
System.setOut(originalOut);

String expectedOutput = "Added to stock: \n"
+ "Ingredient: milk\t\tQty: 100ml\n"
+ "Ingredient: rice\t\tQty: 1000g\n"
+ "Ingredient: chicken\t\tQty: 500g";
+ "Ingredient: milk\nTotal Qty: 100ml\n\n"
+ "Ingredient: rice\nTotal Qty: 1000g\n\n"
+ "Ingredient: chicken\nTotal Qty: 500g\n\n";

assertEquals(expectedOutput.trim().replaceAll("\\s+", " "),
actualOutput.trim().replaceAll("\\s+", " "));
Expand All @@ -65,7 +65,7 @@ void execute_validInputWithExistingIngredient_returnCorrectOutput() {
System.setOut(originalOut);

String expectedOutput = "Added to stock: \n"
+ "Ingredient: chicken\t\tQty: 1000g\n";
+ "Ingredient: chicken\nTotal Qty: 1000g\n";

assertEquals(expectedOutput.trim().replaceAll("\\s+", " "),
actualOutput.trim().replaceAll("\\s+", " "));
Expand Down
23 changes: 20 additions & 3 deletions src/test/java/seedu/cafectrl/parser/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.junit.jupiter.api.Test;
import seedu.cafectrl.command.AddDishCommand;
import seedu.cafectrl.command.BuyIngredientCommand;
import seedu.cafectrl.command.DeleteDishCommand;
import seedu.cafectrl.command.ListIngredientCommand;
import seedu.cafectrl.command.ListSaleByDayCommand;
Expand Down Expand Up @@ -158,7 +157,7 @@ public void parseCommand_missingDeleteIndex_returnsErrorMessage() {
}

@Test
public void parseCommand_invalidDeleteIndex_returnsErrorMessage() {
public void parseCommand_notIntDeleteIndex_returnsErrorMessage() {
Menu menu = new Menu();
Ui ui = new Ui();
Pantry pantry = new Pantry(ui);
Expand All @@ -172,7 +171,25 @@ public void parseCommand_invalidDeleteIndex_returnsErrorMessage() {

IncorrectCommand incorrectCommand = (IncorrectCommand) result;
String feedbackToUser = incorrectCommand.feedbackToUser;
assertEquals(ErrorMessages.MISSING_ARGUMENT_FOR_DELETE, feedbackToUser);
assertEquals(ErrorMessages.DISH_INDEX_NOT_INT, feedbackToUser);
}

@Test
public void parseCommand_invalidDeleteIndex_returnsErrorMessage() {
Menu menu = new Menu();
Ui ui = new Ui();
Pantry pantry = new Pantry(ui);
Sales sales = new Sales();
CurrentDate currentDate = new CurrentDate();
String userInput = "delete -1";
ParserUtil parserUtil = new Parser();
Command result = parserUtil.parseCommand(menu, userInput, ui, pantry, sales, currentDate);

assertTrue(result instanceof IncorrectCommand);

IncorrectCommand incorrectCommand = (IncorrectCommand) result;
String feedbackToUser = incorrectCommand.feedbackToUser;
assertEquals(ErrorMessages.INVALID_DISH_INDEX, feedbackToUser);
}

@Test
Expand Down

0 comments on commit 9032698

Please sign in to comment.