test: increase coverage and add codecov integration

This commit is contained in:
Justineo
2025-09-20 22:47:33 +08:00
committed by GU Yiling
parent e0cf2a4e7e
commit 373fe19d59
31 changed files with 2813 additions and 169 deletions

View File

@ -1,3 +1,5 @@
import { isBrowser } from "./utils";
let registered: boolean | null = null;
export const TAG_NAME = "x-vue-echarts";
@ -11,30 +13,33 @@ export function register(): boolean {
return registered;
}
if (
typeof HTMLElement === "undefined" ||
typeof customElements === "undefined"
) {
return (registered = false);
const registry = globalThis.customElements;
if (!isBrowser() || !registry?.get) {
registered = false;
return registered;
}
try {
class ECElement extends HTMLElement implements EChartsElement {
__dispose: (() => void) | null = null;
if (!registry.get(TAG_NAME)) {
try {
class ECElement extends HTMLElement implements EChartsElement {
__dispose: (() => void) | null = null;
disconnectedCallback() {
if (this.__dispose) {
this.__dispose();
this.__dispose = null;
disconnectedCallback(): void {
if (this.__dispose) {
this.__dispose();
this.__dispose = null;
}
}
}
registry.define(TAG_NAME, ECElement);
} catch {
registered = false;
return registered;
}
if (customElements.get(TAG_NAME) == null) {
customElements.define(TAG_NAME, ECElement);
}
} catch {
return (registered = false);
}
return (registered = true);
registered = true;
return registered;
}