Skip to content

Commit

Permalink
Add leave test
Browse files Browse the repository at this point in the history
  • Loading branch information
nixonwidjaja committed Oct 12, 2023
1 parent de2e3d1 commit d3aaab9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class LeaveCommand extends Command {
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds leave months for an employee.\n"
+ "Parameters: INDEX (must be a positive integer) " + PREFIX_MONTH + "MONTHS\n"
+ "Format: MONTHS must be integers separated by commas without spaces. "
+ "1 - Jan, 2 - Feb, ..., 12 - Dec.\n"
+ "1: Jan, 2: Feb, ..., 12: Dec.\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_MONTH + "3,-4 to add leave in March and remove leave in April.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class CommandTestUtil {
public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol
public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses
public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags
public static final String INVALID_LEAVE = "1+";

public static final String PREAMBLE_WHITESPACE = "\t \r \n";
public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble";
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/seedu/address/model/person/LeaveTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package seedu.address.model.person;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.VALID_LEAVE;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_LEAVE;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.BOB;

import org.junit.jupiter.api.Test;

public class LeaveTest {

@Test
public void validLeave() {
assertEquals(new Leave().leave, Leave.NO_LEAVE);
assertTrue(Leave.isValidLeave(ALICE.getLeave().leave));
assertTrue(Leave.isValidLeave(BOB.getLeave().leave));
assertTrue(Leave.isValidLeave(VALID_LEAVE));
assertFalse(Leave.isValidLeave(INVALID_LEAVE));
assertEquals(new Leave().toString(), "-");
assertEquals(ALICE.getLeave().leave, "111101010101");
assertEquals(ALICE.getLeave().toString(), "Jan, Feb, Mar, Apr, Jun, Aug, Oct, Dec");
}
}
5 changes: 0 additions & 5 deletions src/test/java/seedu/address/model/person/PersonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@

public class PersonTest {

@Test
public void asObservableList_modifyList_throwsUnsupportedOperationException() {
Person person = new PersonBuilder().build();
}

@Test
public void isSamePerson() {
// same object -> returns true
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/testutil/PersonBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public PersonBuilder withLeave(String leave) {
}

public Person build() {
return new Person(name, phone, email, address, salary, claimBudget, department, dob);
return new Person(name, phone, email, address, salary, claimBudget, department, dob, leave);
}

}

0 comments on commit d3aaab9

Please sign in to comment.