StopButton.test.ts 883 B

123456789101112131415161718192021222324252627
  1. import { ButtonInteraction } from "discord.js";
  2. import { PaginationSent } from "djs-button-pages";
  3. import { StopButton } from "../src/Presets";
  4. describe("StopButton: button that stops pagination.", () => {
  5. test("action should call pagination's stop method.", async () => {
  6. const methodMock = jest.fn(),
  7. pagesMock = ({
  8. stop: methodMock,
  9. } as unknown) as PaginationSent,
  10. interactionMock = ({} as unknown) as ButtonInteraction;
  11. const button = new StopButton();
  12. await button.action(pagesMock, interactionMock);
  13. expect(methodMock).toHaveBeenCalled();
  14. });
  15. test("switch should always return false.", async () => {
  16. const pagesMock = ({} as unknown) as PaginationSent;
  17. const button = new StopButton();
  18. expect(await button.switch(pagesMock)).toBeFalsy();
  19. });
  20. });