Initial Commit

This commit is contained in:
2026-05-27 23:47:53 +01:00
parent fbc70f96e6
commit 9b28db724f
18103 changed files with 1600554 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/**
* DTP-08 — folder depth cap.
*/
import { describe, expect, it } from "@suaveplan/testing/runner";
import type { FolderTemplate } from "../src/index.js";
import {
assertFolderDepth,
type DriveTemplateError,
DTP_CODES,
MAX_FOLDER_DEPTH,
} from "../src/index.js";
function chain(depth: number): FolderTemplate {
let node: FolderTemplate = { name: `level-${depth}`, children: [] };
for (let i = depth - 1; i >= 0; i--) {
node = { name: `level-${i}`, children: [node] };
}
return node;
}
describe("DTP-08 — folder depth cap", () => {
it("MAX_FOLDER_DEPTH pinned at 32", { timeout: 5000 }, () => {
expect(MAX_FOLDER_DEPTH).toBe(32);
});
it("depth-32 nested folder accepted", { timeout: 5000 }, () => {
const tree = chain(32);
expect(() => assertFolderDepth(tree)).not.toThrow();
});
it("depth-33 nested folder rejected", { timeout: 5000 }, () => {
const tree = chain(33);
try {
assertFolderDepth(tree);
throw new Error("expected TOO_DEEP");
} catch (err) {
expect((err as DriveTemplateError).code).toBe(
DTP_CODES.TEMPLATE_TOO_DEEP
);
}
});
});