Skip to content

Commit

Permalink
Fix for CI (pt2)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterHW963 committed Sep 19, 2024
1 parent baba855 commit 743415f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions data/nether.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
T| |Chores|Buy groceries
1 change: 1 addition & 0 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void start(Stage stage) {
stage.setMinWidth(417);
stage.setScene(scene);
fxmlLoader.<MainWindow>getController().setNether(nether); // inject the Nether instance
stage.setTitle("Nether");
stage.show();
} catch (IOException e) {
e.printStackTrace();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/nether/task/Task.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package nether.task;

import nether.NetherException;

import java.util.Objects;

import nether.NetherException;

/**
* Represents a task object model with a description and status.
* The {@code Task} class serves as an abstract base class for different types of tasks, providing methods to manage the
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/nether/parser/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void extractCommandWord_commandWords_returnsCorrectWOrds() {
@Test
public void extractInputDetails_validTodoInput_returnsCorrectDetails() throws NetherException {
String[] result = parser.extractInputDetails("todo Read book", "todo");
assertArrayEquals(new String[]{"Read book"}, result);
assertArrayEquals(new String[]{"Read book", ""}, result);
}

@Test
Expand All @@ -55,7 +55,7 @@ public void extractInputDetails_emptyTodoDescription_throwsNetherException() {
@Test
public void extractInputDetails_validDeadlineInput_returnsCorrectDetails() throws NetherException {
String[] result = parser.extractInputDetails("deadline Submit assignment /by 2024-09-01", "deadline");
assertArrayEquals(new String[]{"Submit assignment ", "2024-09-01"}, result);
assertArrayEquals(new String[]{"Submit assignment ", "", "2024-09-01"}, result);
}

@Test
Expand All @@ -77,7 +77,7 @@ void extractInputDetails_missingDeadlineDate_throwsNetherException() {
@Test
void extractInputDetails_validEventInput_returnsCorrectDetails() throws NetherException {
String[] result = parser.extractInputDetails("event Project meeting /from 2024-09-01 /to 2024-09-02", "event");
assertArrayEquals(new String[]{"Project meeting ", "2024-09-01 ", "2024-09-02"}, result);
assertArrayEquals(new String[]{"Project meeting ", "", "2024-09-01 ", "2024-09-02"}, result);
}

@Test
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/nether/task/ToDoTaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ void constructor_withValidDescription_createsTodoTask() {
@Test
void toSaveFormat_withUndoneTask_returnsCorrectFormat() {
TodoTask task = new TodoTask("Buy groceries", "Chores");
assertEquals("T| |Buy groceries", task.toSaveFormat(), "toSaveFormat should return correct "
assertEquals("T| |Chores|Buy groceries", task.toSaveFormat(), "toSaveFormat should return correct "
+ "save string for an undone task.");
}

@Test
void toSaveFormat_withDoneTask_returnsCorrectFormat() {
TodoTask task = new TodoTask("Read a book", "");
task.markAsDone();
assertEquals("T|X|Read a book", task.toSaveFormat(), "toSaveFormat should return correct save "
assertEquals("T|X||Read a book", task.toSaveFormat(), "toSaveFormat should return correct save "
+ "string for a done task.");
}

// Test the toString() method
@Test
void toString_withUndoneTask_returnsCorrectString() {
TodoTask task = new TodoTask("Go jogging", "Exercise");
assertEquals("[T][ ] Go jogging", task.toString(), "toString should match the expected format "
assertEquals("[T][ ] <Exercise> Go jogging", task.toString(), "toString should match the expected format "
+ "for an undone task.");
}

@Test
void toString_withDoneTask_returnsCorrectString() {
TodoTask task = new TodoTask("Do the laundry", "Chores");
task.markAsDone();
assertEquals("[T][X] Do the laundry", task.toString(), "toString should match the expected "
assertEquals("[T][X] <Chores> Do the laundry", task.toString(), "toString should match the expected "
+ "format for a done task.");
}
}

0 comments on commit 743415f

Please sign in to comment.