Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

1.2 KB
Raw Blame
import { afterEach, describe, expect, it, vi } from "vitest";
import { isApplePlatform, keyCombo, modKey } from "@/lib/keys";

describe("modifier key name", () => {
  afterEach(() => vi.unstubAllGlobals());

  it("says ⌘ on Apple devices and Ctrl elsewhere", () => {
    for (const p of ["MacIntel", "iPhone", "iPad", "iPod touch"]) expect(isApplePlatform(p)).toBe(true);
    for (const p of ["Win32", "Linux x86_64", "Linux armv8l", ""]) expect(isApplePlatform(p)).toBe(false);
  });

  it("reads the browser's platform, and says Ctrl where there is none (the server)", () => {
    vi.stubGlobal("navigator", undefined);
    expect(modKey()).toBe("Ctrl");
    vi.stubGlobal("navigator", { platform: "MacIntel" });
    expect(modKey()).toBe("⌘");
    vi.stubGlobal("navigator", { platform: "Win32" });
    expect(modKey()).toBe("Ctrl");
  });
});

describe("shortcuts as the keyboard writes them", () => {
  it("uses Apple's symbols on Apple devices and words with + elsewhere", () => {
    expect(keyCombo("D", { mod: "⌘" })).toBe("⌘D");
    expect(keyCombo("Z", { mod: "⌘", shift: true })).toBe("⇧⌘Z");
    expect(keyCombo("D", { mod: "Ctrl" })).toBe("Ctrl+D");
    expect(keyCombo("Z", { mod: "Ctrl", shift: true })).toBe("Ctrl+Shift+Z");
  });
});