Skip to content

Commit 085eab0

Browse files
committed
fix: Fix tests
1 parent 28dba96 commit 085eab0

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
moduleNameMapper: {
1818
"^vscode$": "<rootDir>/src/test/mock/vscode.ts",
1919
"^@lib$": "<rootDir>/src/test/mock/lib.ts",
20+
"^node-fetch$": "<rootDir>/src/test/mock/node-fetch.ts",
2021
// Development: use local TypeScript source (same as webpack and tsconfig)
2122
"^@altimateai/dbt-integration$":
2223
"<rootDir>/../altimate-dbt-integration/src/index.ts",

src/test/mock/node-fetch.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Mock for node-fetch module
2+
export class AbortError extends Error {
3+
constructor(message: string) {
4+
super(message);
5+
this.name = "AbortError";
6+
}
7+
}
8+
9+
export default jest.fn(() =>
10+
Promise.resolve({
11+
ok: true,
12+
status: 200,
13+
json: () => Promise.resolve({}),
14+
text: () => Promise.resolve(""),
15+
}),
16+
);

src/test/mock/vscode.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ export const DiagnosticSeverity = {
3232
Hint: 3,
3333
};
3434

35+
export const TreeItemCollapsibleState = {
36+
None: 0,
37+
Collapsed: 1,
38+
Expanded: 2,
39+
};
40+
41+
export const TreeItem = class {
42+
constructor(
43+
public label?: string,
44+
public collapsibleState?: number,
45+
) {}
46+
};
47+
3548
export const Diagnostic = class {
3649
constructor(
3750
public range: any,

src/test/setup.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,27 @@ jest.mock("vscode", () => ({
8888
line,
8989
character,
9090
})),
91+
TreeItemCollapsibleState: {
92+
None: 0,
93+
Collapsed: 1,
94+
Expanded: 2,
95+
},
96+
TreeItem: jest.fn().mockImplementation((label, collapsibleState) => ({
97+
label,
98+
collapsibleState,
99+
})),
100+
CancellationTokenSource: jest.fn().mockImplementation(() => ({
101+
token: {
102+
onCancellationRequested: jest.fn(),
103+
isCancellationRequested: false,
104+
},
105+
cancel: jest.fn(),
106+
dispose: jest.fn(),
107+
})),
108+
CancellationToken: {
109+
None: {
110+
onCancellationRequested: jest.fn(),
111+
isCancellationRequested: false,
112+
},
113+
},
91114
}));

0 commit comments

Comments
 (0)