The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | import { splitTransferredFiles } from "./workspaceFileDrop"; |
| 3 | |
| 4 | describe("splitTransferredFiles", () => { |
| 5 | it("separates copied folders from files before attachment validation", () => { |
| 6 | const folder = new File([], "photos.png"); |
| 7 | const emptyFile = new File([], "empty.txt"); |
| 8 | const image = new File(["image"], "photo.png", { type: "image/png" }); |
| 9 | |
| 10 | expect( |
| 11 | splitTransferredFiles({ |
| 12 | files: [folder, emptyFile, image], |
| 13 | items: [ |
| 14 | { |
| 15 | kind: "string", |
| 16 | getAsFile: () => null, |
| 17 | webkitGetAsEntry: () => null, |
| 18 | }, |
| 19 | { |
| 20 | kind: "file", |
| 21 | getAsFile: () => folder, |
| 22 | webkitGetAsEntry: () => ({ isDirectory: true }), |
| 23 | }, |
| 24 | { |
| 25 | kind: "file", |
| 26 | getAsFile: () => emptyFile, |
| 27 | webkitGetAsEntry: () => ({ isDirectory: false }), |
| 28 | }, |
| 29 | { |
| 30 | kind: "file", |
| 31 | getAsFile: () => image, |
| 32 | webkitGetAsEntry: () => null, |
| 33 | }, |
| 34 | ], |
| 35 | }), |
| 36 | ).toEqual({ files: [emptyFile, image], folders: [folder] }); |
| 37 | }); |
| 38 | |
| 39 | it("ignores clipboard file items that cannot provide a file", () => { |
| 40 | expect( |
| 41 | splitTransferredFiles({ |
| 42 | files: [], |
| 43 | items: [ |
| 44 | { |
| 45 | kind: "file", |
| 46 | getAsFile: () => null, |
| 47 | webkitGetAsEntry: () => ({ isDirectory: true }), |
| 48 | }, |
| 49 | ], |
| 50 | }), |
| 51 | ).toEqual({ files: [], folders: [] }); |
| 52 | }); |
| 53 | }); |