Skip to content

Commit 6f3873f

Browse files
committed
fix: handle Windows path separators in open-file tests
1 parent 89e8d35 commit 6f3873f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/integrations/misc/__tests__/open-file.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ describe("openFile", () => {
123123
expect(console.warn).not.toHaveBeenCalled()
124124

125125
// Should use the decoded path - verify it contains the decoded brackets
126-
expect(vscode.Uri.file).toHaveBeenCalledWith(expect.stringContaining("[test]/file.txt"))
126+
// On Windows, the path will include backslashes instead of forward slashes
127+
const expectedPathSegment = process.platform === "win32" ? "[test]\\file.txt" : "[test]/file.txt"
128+
expect(vscode.Uri.file).toHaveBeenCalledWith(expect.stringContaining(expectedPathSegment))
127129
expect(vscode.workspace.openTextDocument).toHaveBeenCalled()
128130
expect(vscode.window.showErrorMessage).not.toHaveBeenCalled()
129131
})
@@ -226,8 +228,10 @@ describe("openFile", () => {
226228

227229
await openFile(newFilePath, { create: true, content })
228230

231+
// On Windows, the path will include backslashes instead of forward slashes
232+
const expectedPathSegment = process.platform === "win32" ? "new\\file.txt" : "new/file.txt"
229233
expect(vscode.workspace.fs.writeFile).toHaveBeenCalledWith(
230-
expect.objectContaining({ fsPath: expect.stringContaining("new/file.txt") }),
234+
expect.objectContaining({ fsPath: expect.stringContaining(expectedPathSegment) }),
231235
Buffer.from(content, "utf8"),
232236
)
233237
expect(vscode.workspace.openTextDocument).toHaveBeenCalled()

0 commit comments

Comments
 (0)