import { expect, openFromTree, test } from "./fixtures";
// A JSX comment is `{/* … */}` among JSX children, while its own text parses as
// JavaScript, where the tokens are `/* … */`. Toggling must still take it back out.
const SRC = `export function App() {
return (
x
);
}
`;
test("⌘/ twice on a JSX line gives the line back", async ({ workbench: page }) => {
await page.evaluate(async (src) => {
const backendModule = "/src/editor/core/backend.ts";
const mod = await import(/* @vite-ignore */ backendModule);
const backend = mod.docBackend() as { files: Map };
backend.files.set("/dev/acme-api/App.tsx", src);
}, SRC);
const editor = await openFromTree(page, "App.tsx");
const content = editor.locator(".cm-content");
await editor.locator(".cm-line", { hasText: "x" }).click();
await page.keyboard.press("Meta+/");
await expect(content).toContainText("{/* x */}");
await page.keyboard.press("Meta+/");
await expect(content).not.toContainText("/*");
await expect(editor.locator(".cm-line", { hasText: "x" })).toHaveText("x");
});