|
1 | 1 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 2 | import { LocalStorageDAO } from "@App/app/repo/localStorage"; |
3 | 3 | import { FileSystemError, isAuthError, isConflictError, isNotFoundError, isRateLimitError } from "../error"; |
| 4 | +import { joinPath } from "../utils"; |
4 | 5 | import GoogleDriveFileSystem from "./googledrive"; |
5 | 6 |
|
6 | 7 | function createMockResponse(options: { ok?: boolean; status?: number; text?: string; json?: any }): Response { |
@@ -82,6 +83,21 @@ describe("GoogleDriveFileSystem", () => { |
82 | 83 | expect(requestSpy).toHaveBeenCalledTimes(1); |
83 | 84 | }); |
84 | 85 |
|
| 86 | + it("create should normalize double slashes in paths", async () => { |
| 87 | + const fs = new GoogleDriveFileSystem("/ScriptCat//sync", "token"); |
| 88 | + |
| 89 | + const writer = await fs.create("dir//file.user.js"); |
| 90 | + |
| 91 | + expect((writer as any).path).toBe("/ScriptCat/sync/dir/file.user.js"); |
| 92 | + }); |
| 93 | + |
| 94 | + it("clearPathCache should accept normalized paths derived from duplicate slashes", () => { |
| 95 | + const fs = new GoogleDriveFileSystem("/ScriptCat//sync", "token"); |
| 96 | + |
| 97 | + expect(joinPath("/ScriptCat//sync", "dir//file.user.js")).toBe("/ScriptCat/sync/dir/file.user.js"); |
| 98 | + expect(() => fs.clearPathCache("/ScriptCat//sync/dir")).not.toThrow(); |
| 99 | + }); |
| 100 | + |
85 | 101 | it("writer should clear stale path cache and retry once on provider 404", async () => { |
86 | 102 | const fs = new GoogleDriveFileSystem("/", "token"); |
87 | 103 | const notFoundError = new FileSystemError({ |
|
0 commit comments