Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

822 B
Raw Blame
import { describe, expect, it } from "vite-plus/test";
import { getCoverCropRect } from "./prepare-avatar-image";

describe("getCoverCropRect", () => {
  it("keeps a square image whole", () => {
    expect(getCoverCropRect(400, 400)).toEqual({
      sourceX: 0,
      sourceY: 0,
      side: 400,
    });
  });

  it("crops a landscape image around its center", () => {
    expect(getCoverCropRect(800, 400)).toEqual({
      sourceX: 200,
      sourceY: 0,
      side: 400,
    });
  });

  it("crops a portrait image around its center", () => {
    expect(getCoverCropRect(400, 900)).toEqual({
      sourceX: 0,
      sourceY: 250,
      side: 400,
    });
  });

  it("rounds an odd offset", () => {
    expect(getCoverCropRect(101, 100)).toEqual({
      sourceX: 1,
      sourceY: 0,
      side: 100,
    });
  });
});