MCPcopy
hub / github.com/YishenTu/claudian / MockElement

Interface MockElement

tests/helpers/mockElement.ts:1–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1export interface MockElement {
2 tagName: string;
3 children: MockElement[];
4 style: Record<string, string>;
5 dataset: Record<string, string>;
6 scrollTop: number;
7 scrollHeight: number;
8 innerHTML: string;
9 textContent: string;
10 className: string;
11 classList: {
12 add: (cls: string) => void;
13 remove: (cls: string) => void;
14 contains: (cls: string) => boolean;
15 toggle: (cls: string, force?: boolean) => boolean;
16 };
17 addClass: (cls: string) => MockElement;
18 removeClass: (cls: string) => MockElement;
19 hasClass: (cls: string) => boolean;
20 getClasses: () => string[];
21 createDiv: (opts?: { cls?: string; text?: string }) => MockElement;
22 createSpan: (opts?: { cls?: string; text?: string }) => MockElement;
23 createEl: (tag: string, opts?: { cls?: string; text?: string; attr?: Record<string, string> }) => MockElement;
24 appendChild: (child: any) => any;
25 insertBefore: (el: MockElement, ref: MockElement | null) => void;
26 firstChild: MockElement | null;
27 remove: () => void;
28 empty: () => void;
29 contains: (node: any) => boolean;
30 scrollIntoView: () => void;
31 setAttribute: (name: string, value: string) => void;
32 getAttribute: (name: string) => string | undefined | null;
33 removeAttribute: (name: string) => void;
34 addEventListener: (event: string, handler: (...args: any[]) => void) => void;
35 removeEventListener: (event: string, handler: (...args: any[]) => void) => void;
36 dispatchEvent: (eventOrType: string | { type: string; [key: string]: any }, extraArg?: any) => void;
37 click: () => void;
38 getEventListenerCount: (event: string) => number;
39 querySelector: (selector: string) => MockElement | null;
40 querySelectorAll: (selector: string) => MockElement[];
41 getBoundingClientRect: () => { top: number; left: number; width: number; height: number; right: number; bottom: number; x: number; y: number; toJSON: () => void };
42 setText: (text: string) => void;
43 appendText: (text: string) => void;
44 setCssProps: (props: Record<string, string>) => void;
45 ownerDocument: {
46 defaultView: {
47 requestAnimationFrame: (callback: FrameRequestCallback) => number;
48 cancelAnimationFrame: (handle: number) => void;
49 setTimeout: (callback: () => void, timeout: number) => number;
50 clearTimeout: (handle: number) => void;
51 setInterval: (callback: () => void, timeout: number) => number;
52 clearInterval: (handle: number) => void;
53 };
54 activeElement?: any;
55 body?: any;
56 addEventListener?: (event: string, handler: (...args: any[]) => void) => void;
57 removeEventListener?: (event: string, handler: (...args: any[]) => void) => void;
58 createElement: (tagName: string) => MockElement;
59 createElementNS: (namespace: string, tagName: string) => MockElement;
60 getSelection?: () => Selection | null;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected