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.

885 B
Raw Blame
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
import { resolveAvatarSrc } from "./resolve-avatar-src";

afterEach(() => {
  vi.unstubAllEnvs();
});

describe("resolveAvatarSrc", () => {
  it("points an uploaded avatar at the API origin", () => {
    vi.stubEnv("VITE_API_URL", "https://api.example.com");

    expect(resolveAvatarSrc("/api/user/avatar/abc123")).toBe(
      "https://api.example.com/api/user/avatar/abc123",
    );
  });

  it("leaves provider avatars untouched", () => {
    vi.stubEnv("VITE_API_URL", "https://api.example.com");

    expect(resolveAvatarSrc("https://avatars.githubusercontent.com/u/1")).toBe(
      "https://avatars.githubusercontent.com/u/1",
    );
  });

  it("passes through empty and undefined values", () => {
    expect(resolveAvatarSrc("")).toBe("");
    expect(resolveAvatarSrc(undefined)).toBeUndefined();
  });
});