mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-09 18:06:45 +08:00
Expose the supported PowerShell installer alongside the existing macOS/Linux command in the runtime dialog, onboarding, and landing download section.
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
CLI_INSTALL_COMMANDS,
|
|
CliInstallCommand,
|
|
} from "./cli-install-command";
|
|
|
|
const LABELS = {
|
|
group: "Choose your platform",
|
|
macosLinux: "macOS / Linux",
|
|
windows: "Windows",
|
|
};
|
|
|
|
function renderSwitch() {
|
|
return render(
|
|
<CliInstallCommand labels={LABELS}>
|
|
{(command) => <code>{command}</code>}
|
|
</CliInstallCommand>,
|
|
);
|
|
}
|
|
|
|
describe("CliInstallCommand", () => {
|
|
it("defaults to the macOS / Linux installer", () => {
|
|
renderSwitch();
|
|
|
|
expect(
|
|
screen.getByRole("tablist", { name: LABELS.group }),
|
|
).toBeInTheDocument();
|
|
expect(screen.getByRole("tab", { name: "macOS / Linux" })).toHaveAttribute(
|
|
"aria-selected",
|
|
"true",
|
|
);
|
|
expect(
|
|
screen.getByText(CLI_INSTALL_COMMANDS.macosLinux),
|
|
).toBeInTheDocument();
|
|
expect(screen.queryByText(CLI_INSTALL_COMMANDS.windows)).toBeNull();
|
|
});
|
|
|
|
it("hands the Windows command to the row when that tab is picked", async () => {
|
|
const user = userEvent.setup();
|
|
renderSwitch();
|
|
|
|
await user.click(screen.getByRole("tab", { name: "Windows" }));
|
|
|
|
expect(screen.getByRole("tab", { name: "Windows" })).toHaveAttribute(
|
|
"aria-selected",
|
|
"true",
|
|
);
|
|
expect(screen.getByText(CLI_INSTALL_COMMANDS.windows)).toBeInTheDocument();
|
|
expect(screen.queryByText(CLI_INSTALL_COMMANDS.macosLinux)).toBeNull();
|
|
});
|
|
|
|
// A real tablist: arrow keys move between platforms without a click.
|
|
it("switches platform with the arrow keys", async () => {
|
|
const user = userEvent.setup();
|
|
renderSwitch();
|
|
|
|
await user.click(screen.getByRole("tab", { name: "macOS / Linux" }));
|
|
await user.keyboard("{ArrowRight}");
|
|
|
|
expect(screen.getByText(CLI_INSTALL_COMMANDS.windows)).toBeInTheDocument();
|
|
});
|
|
});
|