Just a whole lot of crap
This commit is contained in:
110
tests/tui/components/common/Pagination.test.js
Normal file
110
tests/tui/components/common/Pagination.test.js
Normal file
@@ -0,0 +1,110 @@
|
||||
const React = require("react");
|
||||
const {
|
||||
Pagination,
|
||||
SimplePagination,
|
||||
} = require("../../../../src/tui/components/common/Pagination.jsx");
|
||||
|
||||
describe("Pagination Component", () => {
|
||||
it("should create Pagination component with default props", () => {
|
||||
const component = React.createElement(Pagination);
|
||||
|
||||
expect(component).toBeDefined();
|
||||
expect(component.type).toBe(Pagination);
|
||||
});
|
||||
|
||||
it("should accept pagination props", () => {
|
||||
const mockOnPageChange = jest.fn();
|
||||
const component = React.createElement(Pagination, {
|
||||
currentPage: 2,
|
||||
totalPages: 5,
|
||||
totalItems: 50,
|
||||
itemsPerPage: 10,
|
||||
onPageChange: mockOnPageChange,
|
||||
});
|
||||
|
||||
expect(component.props.currentPage).toBe(2);
|
||||
expect(component.props.totalPages).toBe(5);
|
||||
expect(component.props.totalItems).toBe(50);
|
||||
expect(component.props.itemsPerPage).toBe(10);
|
||||
expect(component.props.onPageChange).toBe(mockOnPageChange);
|
||||
});
|
||||
|
||||
it("should accept display options", () => {
|
||||
const component = React.createElement(Pagination, {
|
||||
showItemCount: false,
|
||||
showPageNumbers: false,
|
||||
showNavigation: false,
|
||||
compact: true,
|
||||
});
|
||||
|
||||
expect(component.props.showItemCount).toBe(false);
|
||||
expect(component.props.showPageNumbers).toBe(false);
|
||||
expect(component.props.showNavigation).toBe(false);
|
||||
expect(component.props.compact).toBe(true);
|
||||
});
|
||||
|
||||
it("should accept disabled prop", () => {
|
||||
const component = React.createElement(Pagination, {
|
||||
disabled: true,
|
||||
});
|
||||
|
||||
expect(component.props.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it("should handle edge cases with props", () => {
|
||||
const component = React.createElement(Pagination, {
|
||||
currentPage: 0,
|
||||
totalPages: 1,
|
||||
totalItems: 5,
|
||||
itemsPerPage: 10,
|
||||
});
|
||||
|
||||
expect(component.props.currentPage).toBe(0);
|
||||
expect(component.props.totalPages).toBe(1);
|
||||
expect(component.props.totalItems).toBe(5);
|
||||
});
|
||||
|
||||
it("should accept onPageChange callback", () => {
|
||||
const mockCallback = jest.fn();
|
||||
const component = React.createElement(Pagination, {
|
||||
onPageChange: mockCallback,
|
||||
});
|
||||
|
||||
expect(component.props.onPageChange).toBe(mockCallback);
|
||||
});
|
||||
});
|
||||
|
||||
describe("SimplePagination Component", () => {
|
||||
it("should create SimplePagination component", () => {
|
||||
const component = React.createElement(SimplePagination, {
|
||||
currentPage: 1,
|
||||
totalPages: 5,
|
||||
});
|
||||
|
||||
expect(component).toBeDefined();
|
||||
expect(component.type).toBe(SimplePagination);
|
||||
expect(component.props.currentPage).toBe(1);
|
||||
expect(component.props.totalPages).toBe(5);
|
||||
});
|
||||
|
||||
it("should accept onPageChange callback", () => {
|
||||
const mockCallback = jest.fn();
|
||||
const component = React.createElement(SimplePagination, {
|
||||
currentPage: 0,
|
||||
totalPages: 3,
|
||||
onPageChange: mockCallback,
|
||||
});
|
||||
|
||||
expect(component.props.onPageChange).toBe(mockCallback);
|
||||
});
|
||||
|
||||
it("should accept disabled prop", () => {
|
||||
const component = React.createElement(SimplePagination, {
|
||||
currentPage: 1,
|
||||
totalPages: 5,
|
||||
disabled: true,
|
||||
});
|
||||
|
||||
expect(component.props.disabled).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user