PreviousPageButton.test.ts 769 B

123456789101112131415161718192021
  1. import PreviousPageButton from "../../src/Classes/Buttons/PreviousPageButton";
  2. import PaginationData from "../../src/Classes/Paginations/Basic/PaginationData";
  3. describe("Button that switches pagination to the previous page", () => {
  4. test("should initialize with action and disableWhen that equals to zero.", async () => {
  5. const button = new PreviousPageButton();
  6. expect(button.disableWhen).toBe(0);
  7. const dataMock: PaginationData = ({
  8. currentPage: 5,
  9. } as unknown) as PaginationData;
  10. if (!(button.action instanceof Function))
  11. throw new Error("Action should be a function!");
  12. const result = await button.action(dataMock);
  13. expect(result).toBe(dataMock.currentPage - 1);
  14. });
  15. });