import { describe, expect, it } from "vitest"; import { parseIdeaKeymap } from "../ideaKeymap"; import { PRESETS, PRESET_TITLES } from "../keymap"; import { resharperMacos } from "./resharper-macos"; import { resharperWindows } from "./resharper-windows"; import { visualStudioMacos } from "./visualstudio-macos"; import { visualStudioWindows } from "./visualstudio-windows"; /** Actions bound to `key` in `keymap`. */ const owners = (keymap: Record, key: string) => Object.entries(keymap) .filter(([, keys]) => keys.includes(key)) .map(([id]) => id) .sort(); describe("Visual Studio and ReSharper keymaps", () => { it("are available as presets", () => { expect(PRESETS["visualstudio-windows"]).toBe(visualStudioWindows); expect(PRESETS["resharper-windows"]).toBe(resharperWindows); expect(PRESETS["visualstudio-macos"]).toBe(visualStudioMacos); expect(PRESETS["resharper-macos"]).toBe(resharperMacos); expect(PRESET_TITLES["visualstudio-windows"]).toBe("Visual Studio"); expect(PRESET_TITLES["resharper-windows"]).toBe("ReSharper"); }); it("use Visual Studio's debugger and navigation keys", () => { expect(visualStudioWindows["debug.resume"]).toEqual(["F5"]); expect(visualStudioWindows["debug.stepOver"]).toEqual(["F10"]); expect(visualStudioWindows["debug.stepInto"]).toEqual(["F11"]); expect(visualStudioWindows["build.buildProject"]).toEqual(["F7"]); expect(visualStudioWindows["navigate.declaration"]).toEqual(["F12"]); expect(visualStudioWindows["find.usages"]).toEqual(["Shift+F12"]); // F9 toggles a breakpoint; Resume moved to F5 instead of keeping IDEA's F9. expect(owners(visualStudioWindows, "F9")).toEqual(["debug.toggleBreakpoint"]); }); it("layer ReSharper's keys over Visual Studio's", () => { expect(visualStudioWindows["refactor.rename"]).toEqual(["Ctrl+R R", "Ctrl+R Ctrl+R"]); expect(resharperWindows["refactor.rename"]).toEqual(["F2"]); expect(resharperWindows["code.showIntentions"]).toContain("Alt+Enter"); expect(resharperWindows["navigate.declaration"]).toEqual(["Ctrl+B"]); // Inherited from Visual Studio. expect(resharperWindows["debug.stepOver"]).toEqual(["F10"]); }); it("take a key from an inherited action that has no context of its own", () => { // Ctrl+. shows context actions, so it no longer folds the selection. expect(owners(visualStudioWindows, "Ctrl+.")).toEqual(["code.showIntentions"]); // Ctrl+Shift+H is Replace in Files, not Shelve Silently. expect(owners(resharperWindows, "Ctrl+Shift+H")).toEqual(["find.replaceInPath"]); expect(owners(visualStudioMacos, "F10")).toEqual(["debug.stepOver"]); }); it("keep the trackpad swipes for history on macOS", () => { expect(visualStudioMacos["navigate.back"]).toContain("SwipeRight"); expect(resharperMacos["navigate.forward"]).toContain("SwipeLeft"); }); it("are the parents of imported IDEA keymaps based on them", () => { const parent = (name: string) => parseIdeaKeymap(``).parent; expect(parent("Visual Studio")).toBe("visualstudio-windows"); expect(parent("Visual Studio OSX")).toBe("visualstudio-macos"); expect(parent("ReSharper")).toBe("resharper-windows"); expect(parent("ReSharper OSX")).toBe("resharper-macos"); expect(parent("NetBeans 6.5")).toBe("netbeans-windows"); }); });