1import type * as Electron from "electron";
2import { beforeEach, expect, it, vi } from "vite-plus/test";
3
4const switches = vi.hoisted(() => new Set<string>());
5vi.mock("electron", () => ({
6 app: {
7 commandLine: {
8 hasSwitch: (name: string) => switches.has(name),
9 appendSwitch: (name: string) => switches.add(name),
10 removeSwitch: (name: string) => switches.delete(name),
11 },
12 },
13}));
14
15import { showWindowsCaptureOverlay } from "./WindowsCaptureFeedback.ts";
16
17const animationSwitch = "wm-window-animations-disabled";
18
19function overlay(showInactive: () => void) {
20 return { showInactive } as Electron.BaseWindow;
21}
22
23beforeEach(() => {
24 switches.clear();
25 switches.add("unrelated-switch");
26});
27
28it("disables Chromium window animation only while showing the capture overlay", () => {
29 const flagsDuringShow: string[][] = [];
30
31 showWindowsCaptureOverlay(overlay(() => flagsDuringShow.push([...switches])));
32
33 expect(flagsDuringShow).toEqual([["unrelated-switch", animationSwitch]]);
34 expect([...switches]).toEqual(["unrelated-switch"]);
35});