Skip to content

Commit d33e1a6

Browse files
fix: improve JSDOM mock robustness based on PR feedback
1 parent b029097 commit d33e1a6

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • workspace-mcp-server/src/__tests__/mocks

workspace-mcp-server/src/__tests__/mocks/jsdom.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,24 @@
1414

1515
class MockElement {
1616
tagName: string;
17-
textContent: string;
1817
nodeType: number;
1918
childNodes: MockNode[];
2019
nextSibling: MockNode | null;
2120
attributes: { [key: string]: string };
2221

2322
constructor(tagName: string) {
2423
this.tagName = tagName;
25-
this.textContent = '';
2624
this.nodeType = 1; // Element node
2725
this.childNodes = [];
2826
this.nextSibling = null;
2927
this.attributes = {};
3028
}
3129

30+
get textContent(): string {
31+
return this.childNodes.map(child => child.textContent).join('');
32+
}
33+
34+
3235
toLowerCase() {
3336
return this.tagName.toLowerCase();
3437
}
@@ -68,7 +71,7 @@ class MockDocument {
6871
querySelector(selector: string): MockElement | null {
6972
// Simple implementation for our use case (mostly just tag names)
7073
const tagName = selector.toUpperCase();
71-
74+
7275
const queue: MockNode[] = [...this.body.childNodes];
7376
while (queue.length > 0) {
7477
const node = queue.shift()!;

0 commit comments

Comments
 (0)