Sha256: f427ee1e0a3c8a69338ec2cabb73b56a38be6e198eda6be5a32aab7b4900a5e5
Contents?: true
Size: 994 Bytes
Versions: 13
Compression:
Stored size: 994 Bytes
Contents
import { updateComponent } from "./update-component"; import { describe, it, expect } from "vitest"; describe("updateComponent", () => { it("updates the component", () => { const component = document.createElement("div"); component.innerHTML = `<div data-component="TestComponent" data-state='{"testAttribute": "initial"}'></div>`; const input = document.createElement("div"); input.innerHTML = `<input value="updated" data-attribute="testAttribute">`; class TestComponent { state: any; constructor(state: any) { this.state = state; } get render() { return `<div>${this.state.testAttribute}</div>`; } }; (window as any).TestComponent = TestComponent; updateComponent( component.firstChild as HTMLElement, JSON.parse(component.getAttribute("data-state") || "{}"), "testAttribute", input.firstChild as HTMLInputElement ); expect(component.textContent).toBe("updated"); }); });
Version data entries
13 entries across 13 versions & 1 rubygems