presentationPreviewControls.test.ts 826 B

123456789101112131415161718192021
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. clampPresentationPageNumber,
  4. clampPresentationZoomPercent,
  5. } from "@/presentation/presentationPreviewControls.js";
  6. describe("presentation preview controls", () => {
  7. it("clamps page numbers to the available slide range", () => {
  8. expect(clampPresentationPageNumber(-2, 8)).toBe(1);
  9. expect(clampPresentationPageNumber(3.6, 8)).toBe(4);
  10. expect(clampPresentationPageNumber(99, 8)).toBe(8);
  11. expect(clampPresentationPageNumber(Number.NaN, 8)).toBe(1);
  12. });
  13. it("clamps zoom to the supported range", () => {
  14. expect(clampPresentationZoomPercent(1)).toBe(25);
  15. expect(clampPresentationZoomPercent(137.7)).toBe(138);
  16. expect(clampPresentationZoomPercent(999)).toBe(300);
  17. expect(clampPresentationZoomPercent(Number.NaN)).toBe(100);
  18. });
  19. });