Skip to content

Commit

Permalink
added collapsiblePanelTest
Browse files Browse the repository at this point in the history
  • Loading branch information
lauracadillo committed Oct 3, 2024
1 parent 189710d commit 4e7f89a
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.marginallyclever.makelangelo;

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

import javax.swing.*;
import java.awt.*;

import static org.junit.jupiter.api.Assertions.*;

class CollapsiblePanelTest {

private CollapsiblePanel collapsiblePanel;
private JFrame testFrame;

@BeforeEach
void setUp() {
testFrame = new JFrame();
collapsiblePanel = new CollapsiblePanel(testFrame, "Test Panel", 400, true);
}


@Test
void testAddComponent() {
JButton testButton = new JButton("Test Button");
collapsiblePanel.add(testButton);
assertEquals(1, collapsiblePanel.getComponentCount(), "There should be one component in the panel.");
assertFalse(testButton.isVisible(), "The component should be hidden by default.");
}

@Test
void testToggleVisibility() {
JButton testButton = new JButton("Test Button");
collapsiblePanel.add(testButton);

// Simulate click to expand
collapsiblePanel.toggleVisibility(true);
assertTrue(testButton.isVisible(), "The button should be visible after expanding.");

// Simulate click to collapse
collapsiblePanel.toggleVisibility(false);
assertFalse(testButton.isVisible(), "The button should be hidden after collapsing.");
}

@Test
void testSetTitle() {
collapsiblePanel.setTitle("New Title");
assertEquals("New Title", collapsiblePanel.getTitle(), "The title should be updated.");
}
}

0 comments on commit 4e7f89a

Please sign in to comment.