Consolidate Lit repositories: figma-to-lit, figma_lit_example, lit-3d-piano, lit-calculator, lit-code-editor, lit-draggable-dom, lit-file-based-routing, lit-force-graph, lit-html-editor, lit-html-table, lit-modules, lit-native, lit-node-editor, lit-sheet-music, lit-starter-ts, lit-vscode-extension, lit-wmr, vite-lit-capacitor, vite-lit-element-starter, vite-rxdb-lit

This commit is contained in:
2026-05-16 22:17:12 -07:00
parent 4dc3c8a3ff
commit 95667e3038
527 changed files with 63872 additions and 54 deletions
+44
View File
@@ -0,0 +1,44 @@
import type { IWindow } from "happy-dom";
import { beforeEach, describe, expect, it, vi } from "vitest";
import "../src/my-element";
declare global {
interface Window extends IWindow {}
}
describe("Button with increment", async () => {
beforeEach(async () => {
document.body.innerHTML = '<my-element name="World"></my-element>';
await window.happyDOM.whenAsyncComplete();
await new Promise((resolve) => setTimeout(resolve, 0));
});
function getInsideButton(): HTMLElement | null | undefined {
return document.body
.querySelector("my-element")
?.shadowRoot?.querySelector("button");
}
it("should increment the count on each click", () => {
getInsideButton()?.click();
expect(getInsideButton()?.innerText).toContain("1");
});
it("should show name props", () => {
getInsideButton();
expect(
document.body.querySelector("my-element")?.shadowRoot?.innerHTML
).toContain("World");
});
it("should dispatch count event on button click", () => {
const spyClick = vi.fn();
document.querySelector("my-element")!.addEventListener("count", spyClick);
getInsideButton()?.click();
expect(spyClick).toHaveBeenCalled();
});
});