fix(tests): Improve decorator tests and add LitElement component tests for better validation
This commit is contained in:
		
							
								
								
									
										37
									
								
								test/ts_web/test-lit.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								test/ts_web/test-lit.ts
									
									
									
									
									
										Normal 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); | ||||
		Reference in New Issue
	
	Block a user