import { describe, it } from 'vitest' import { fixture } from '@open-wc/testing-helpers' import { customElementIfNotExist } from './customElementIfNotExist' describe('customElementIfNotExist()', () => { it('should create custom element if it does not exist', async () => { const tag = 'my-element' @customElementIfNotExist(tag) // @ts-ignore class MyElement extends HTMLElement { connectedCallback() { this.innerHTML = 'Hello, World!' } } const el = await fixture(`<${tag}>`) expect(el).toBeDefined() expect(el.innerHTML).toBe('Hello, World!') }) it('should not create custom element if it already exists', async () => { const tag = 'my-element' customElements.define(tag, class MyElement extends HTMLElement {}) @customElementIfNotExist(tag) // @ts-ignore class MyElement2 extends HTMLElement {} const el = await fixture(`<${tag}>`) expect(el.constructor.name).toBe('MyElement') }) })