feat: select all files or one folder for project restoration

This commit is contained in:
muena
2026-10-20 11:27:11 +02:00
parent 731c449c33
commit 41b935a145
3 changed files with 101 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
import { describe, expect, it } from "bun:test";
import { listRestorableFolders, selectRestorableFolder } from "../src/lib/restore-file-selection";
import type { ProjectFile } from "../src/lib/velum-project";
const files: ProjectFile[] = [
{ relPath: "A/Notiz.txt", absPath: "", kind: "text", size: 0 },
{ relPath: "A/Unterordner/Tabelle.xlsx", absPath: "", kind: "document", size: 0 },
{ relPath: "AB/Nachbar.txt", absPath: "", kind: "text", size: 0 },
{ relPath: "Wurzel.txt", absPath: "", kind: "text", size: 0 },
];
describe("Ordnerauswahl beim Klartext-Export", () => {
it("zeigt übergeordnete Ordner mit der Anzahl ihrer Unterordner-Dateien", () => {
expect(listRestorableFolders(files)).toEqual([
{ path: "A", fileCount: 2, textCount: 1, documentCount: 1 },
{ path: "A/Unterordner", fileCount: 1, textCount: 0, documentCount: 1 },
{ path: "AB", fileCount: 1, textCount: 1, documentCount: 0 },
]);
});
it("wählt nur den gewählten Ordner rekursiv und keine ähnlich benannten Nachbarn", () => {
expect([...selectRestorableFolder(files, "A")]).toEqual([
"A/Notiz.txt",
]);
expect([...selectRestorableFolder(files, "A", true)]).toEqual([
"A/Notiz.txt", "A/Unterordner/Tabelle.xlsx",
]);
});
});