fix(tests): Improve decorator tests and add LitElement component tests for better validation

This commit is contained in:
Juergen Kunz
2025-06-26 19:58:45 +00:00
parent bbe96ea1f5
commit 40d6b8c40d
4 changed files with 85 additions and 1 deletions

37
test/ts_web/test-lit.ts Normal file
View File

@ -0,0 +1,37 @@
import { LitElement, html, css } from 'lit';
import { customElement, property } from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
static styles = css`
:host {
display: block;
padding: 16px;
}
`;
@property({ type: String })
name = 'World';
@property({ type: Number })
count = 0;
render() {
return html`
<h1>Hello, ${this.name}!</h1>
<button @click=${this._onClick}>
Click Count: ${this.count}
</button>
`;
}
private _onClick() {
this.count++;
}
}
// Test instantiation
const element = new MyElement();
console.log('Element created:', element);
console.log('Element name:', element.name);
console.log('Element count:', element.count);