import * as React from "react"; import { screen } from "@testing-library/react"; import { PaginationItemRangeIndicator as ItemRangeIndicator } from "./PaginationItemRangeIndicator"; import { renderWithContext } from "./paginationTestsHelpers"; const props = { css: {}, page: 1, endlessPagination: false, showTotal: true, items: 100, totalPages: 10, showItems: true, }; describe("PaginationItemRangeIndicator", () => { test("renders visibly into the document", () => { renderWithContext( , { ...props } ); expect(screen.getByText("Showing 1 - 10 of 100 items")).toBeVisible(); }); test("showTotal is false", () => { renderWithContext( , { ...props } ); expect(screen.getByText("Showing 1 - 10 items")).toBeVisible(); }); test("endlessPagination is true", () => { renderWithContext( , { ...props, endlessPagination: true } ); expect( screen.queryByText("Showing 1 - 10 of 100 items") ).not.toBeInTheDocument(); }); test("showItems is false", () => { renderWithContext( , { ...props, showItems: false } ); expect( screen.queryByText("Showing 1 - 10 of 100 items") ).not.toBeInTheDocument(); }); test("fewer than 10 items", () => { renderWithContext( , { ...props } ); expect(screen.getByText("Showing 1 - 9 of 9 items")).toBeVisible(); }); test("page equals totalPages", () => { renderWithContext( , { ...props, page: 10 } ); expect(screen.getByText("Showing 91 - 100 of 100 items")).toBeVisible(); }); });