Skip to content

Commit

Permalink
Add test cases for PaginationPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
wuzengfu committed Nov 11, 2024
1 parent e4b3871 commit 2166447
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/test/java/seedu/address/ui/PaginationPanelTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package seedu.address.ui;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static seedu.address.testutil.Assert.assertThrows;

import java.util.ArrayList;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.embed.swing.JFXPanel;
import seedu.address.model.contact.Contact;

public class PaginationPanelTest {
@BeforeAll
public static void initJavaFxPlatform() {
new JFXPanel();
}

@Test
public void constructor_null_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new PaginationPanel(null));
}

@Test
public void constructor_validObservationList_success() {
ObservableList<Contact> observableList = FXCollections.observableList(new ArrayList<>());
assertDoesNotThrow(() -> new PaginationPanel(observableList));
}

@Test
public void convertItemIndexToDisplayIndex_invalidIndex_throwsAssertionError() {
assertThrows(AssertionError.class, () -> PaginationPanel.convertItemIndexToDisplayIndex(-1));
}

@Test
public void convertItemIndexToDisplayIndex_validIndex_success() {
assertEquals(1, PaginationPanel.convertItemIndexToDisplayIndex(0));
assertEquals(10, PaginationPanel.convertItemIndexToDisplayIndex(9));
}
}

0 comments on commit 2166447

Please sign in to comment.