30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
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",
|
|
]);
|
|
});
|
|
});
|