Skip to content

Commit 3d7125a

Browse files
committed
Fix type errors
1 parent fc427fa commit 3d7125a

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

src/services/code-index/processors/__tests__/scanner.spec.ts

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ describe("DirectoryScanner", () => {
6464
let mockCodeParser: any
6565
let mockCacheManager: any
6666
let mockIgnoreInstance: any
67+
let mockStats: any
6768

6869
beforeEach(async () => {
6970
mockEmbedder = {
@@ -103,19 +104,56 @@ describe("DirectoryScanner", () => {
103104
mockIgnoreInstance,
104105
)
105106

106-
// Mock default implementations
107-
vi.mocked(stat).mockResolvedValue({ size: 1024 })
107+
// Mock default implementations - create proper Stats object
108+
mockStats = {
109+
size: 1024,
110+
isFile: () => true,
111+
isDirectory: () => false,
112+
isBlockDevice: () => false,
113+
isCharacterDevice: () => false,
114+
isSymbolicLink: () => false,
115+
isFIFO: () => false,
116+
isSocket: () => false,
117+
dev: 0,
118+
ino: 0,
119+
mode: 0,
120+
nlink: 0,
121+
uid: 0,
122+
gid: 0,
123+
rdev: 0,
124+
blksize: 0,
125+
blocks: 0,
126+
atimeMs: 0,
127+
mtimeMs: 0,
128+
ctimeMs: 0,
129+
birthtimeMs: 0,
130+
atime: new Date(),
131+
mtime: new Date(),
132+
ctime: new Date(),
133+
birthtime: new Date(),
134+
atimeNs: BigInt(0),
135+
mtimeNs: BigInt(0),
136+
ctimeNs: BigInt(0),
137+
birthtimeNs: BigInt(0),
138+
}
139+
vi.mocked(stat).mockResolvedValue(mockStats)
108140

109141
// Get and mock the listFiles function
110142
const { listFiles } = await import("../../../glob/list-files")
111-
vi.mocked(listFiles).mockResolvedValue([["test/file1.js", "test/file2.js"], []])
143+
vi.mocked(listFiles).mockResolvedValue([["test/file1.js", "test/file2.js"], false])
112144
})
113145

114146
describe("scanDirectory", () => {
115147
it("should skip files larger than MAX_FILE_SIZE_BYTES", async () => {
116148
const { listFiles } = await import("../../../glob/list-files")
117-
vi.mocked(listFiles).mockResolvedValue([["test/file1.js"], []])
118-
vi.mocked(stat).mockResolvedValueOnce({ size: 2 * 1024 * 1024 }) // 2MB > 1MB limit
149+
vi.mocked(listFiles).mockResolvedValue([["test/file1.js"], false])
150+
151+
// Create large file mock stats
152+
const largeFileStats = {
153+
...mockStats,
154+
size: 2 * 1024 * 1024, // 2MB > 1MB limit
155+
}
156+
vi.mocked(stat).mockResolvedValueOnce(largeFileStats)
119157

120158
const result = await scanner.scanDirectory("/test")
121159
expect(result.stats.skipped).toBe(1)
@@ -124,7 +162,7 @@ describe("DirectoryScanner", () => {
124162

125163
it("should parse changed files and return code blocks", async () => {
126164
const { listFiles } = await import("../../../glob/list-files")
127-
vi.mocked(listFiles).mockResolvedValue([["test/file1.js"], []])
165+
vi.mocked(listFiles).mockResolvedValue([["test/file1.js"], false])
128166
const mockBlocks: any[] = [
129167
{
130168
file_path: "test/file1.js",

0 commit comments

Comments
 (0)