-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ts
More file actions
93 lines (86 loc) · 2.05 KB
/
Copy pathsetup.ts
File metadata and controls
93 lines (86 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Test setup file
// This file runs before each test file
// Mock console methods to reduce noise in tests
global.console = {
...console,
log: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
info: jest.fn(),
debug: jest.fn(),
};
// Mock fs-extra to avoid file system operations in tests
jest.mock("fs-extra", () => ({
access: jest.fn(),
readFile: jest.fn(),
writeFile: jest.fn(),
ensureDir: jest.fn(),
copy: jest.fn(),
move: jest.fn(),
remove: jest.fn(),
pathExists: jest.fn().mockResolvedValue(false),
readJson: jest.fn().mockResolvedValue({}),
readdir: jest.fn().mockResolvedValue([]),
}));
// Mock simple-git to avoid git operations in tests
jest.mock("simple-git", () => {
return jest.fn().mockImplementation(() => ({
clone: jest.fn(),
pull: jest.fn(),
checkout: jest.fn(),
log: jest.fn(),
status: jest.fn(),
}));
});
// Mock tree-sitter parsers to avoid native dependencies in tests
jest.mock("tree-sitter-javascript", () => ({}));
jest.mock("tree-sitter-typescript", () => ({}));
jest.mock("tree-sitter-python", () => ({}));
jest.mock("tree-sitter-java", () => ({}));
jest.mock("tree-sitter-rust", () => ({}));
// Global test utilities
global.createMockContext = () => ({
octokit: {
pulls: {
get: jest.fn(),
listFiles: jest.fn(),
},
repos: {
getContent: jest.fn(),
},
issues: {
createComment: jest.fn(),
},
},
payload: {
repository: {
owner: { login: "test-owner" },
name: "test-repo",
},
pull_request: {
number: 1,
head: { sha: "test-sha" },
},
},
});
global.createMockDiff = () => `
diff --git a/src/app.js b/src/app.js
index 1234567..abcdefg 100644
--- a/src/app.js
+++ b/src/app.js
@@ -10,6 +10,10 @@
+function calculateInterest(principal, rate, time) {
+ if (principal <= 0 || rate < 0 || time <= 0) {
+ throw new Error('Invalid parameters');
+ }
+ return principal * rate * time;
+}
`;
global.createMockChangedFiles = () => [
{
filename: "src/app.js",
status: "modified",
additions: 5,
deletions: 0,
},
];