Initial Commit
This commit is contained in:
120
packages/foundation/data/templates/tests/dep-graph.test.ts
Normal file
120
packages/foundation/data/templates/tests/dep-graph.test.ts
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Dependency-graph smoke test.
|
||||
*
|
||||
* Verifies that the package can be loaded and that the core exports resolve
|
||||
* to the expected types without import errors. This acts as a runtime
|
||||
* canary for tree-shaking and circular-dependency regressions.
|
||||
*/
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
describe("dep-graph", () => {
|
||||
it("imports TemplateEngine without errors", {
|
||||
timeout: 30000,
|
||||
}, async () => {
|
||||
const { TemplateEngine } = await import(
|
||||
"../src/engine/TemplateEngine.js"
|
||||
);
|
||||
expect(typeof TemplateEngine).toBe("function");
|
||||
});
|
||||
|
||||
it("imports all error classes", { timeout: 30000 }, async () => {
|
||||
const { TemplateError, PluginError, MaxDepthError } = await import(
|
||||
"../src/errors/template-error.js"
|
||||
);
|
||||
expect(typeof TemplateError).toBe("function");
|
||||
expect(typeof PluginError).toBe("function");
|
||||
expect(typeof MaxDepthError).toBe("function");
|
||||
});
|
||||
|
||||
it("imports all preset factories", { timeout: 30000 }, async () => {
|
||||
const { minimalPreset } = await import("../src/presets/minimal.js");
|
||||
const { standardPreset } = await import("../src/presets/standard.js");
|
||||
const { fullPreset, fullPresetWithLoops } = await import(
|
||||
"../src/presets/full.js"
|
||||
);
|
||||
expect(typeof minimalPreset).toBe("function");
|
||||
expect(typeof standardPreset).toBe("function");
|
||||
expect(typeof fullPreset).toBe("function");
|
||||
expect(typeof fullPresetWithLoops).toBe("function");
|
||||
});
|
||||
|
||||
it("imports all plugin factories", { timeout: 30000 }, async () => {
|
||||
const { createDotNotationPlugin } = await import(
|
||||
"../src/plugins/variables/DotNotationPlugin.js"
|
||||
);
|
||||
const { createArrayIndexPlugin } = await import(
|
||||
"../src/plugins/variables/ArrayIndexPlugin.js"
|
||||
);
|
||||
const { createCaseTransformPlugin } = await import(
|
||||
"../src/plugins/transform/CaseTransformPlugin.js"
|
||||
);
|
||||
const { createRegexPlugin } = await import(
|
||||
"../src/plugins/transform/RegexPlugin.js"
|
||||
);
|
||||
const { createStringSplitPlugin } = await import(
|
||||
"../src/plugins/transform/StringSplitPlugin.js"
|
||||
);
|
||||
const { createCounterPlugin } = await import(
|
||||
"../src/plugins/dynamic/CounterPlugin.js"
|
||||
);
|
||||
const { createDateTimePlugin } = await import(
|
||||
"../src/plugins/dynamic/DateTimePlugin.js"
|
||||
);
|
||||
const { createUuidPlugin } = await import(
|
||||
"../src/plugins/dynamic/UuidPlugin.js"
|
||||
);
|
||||
const { createConditionalPlugin } = await import(
|
||||
"../src/plugins/control/ConditionalPlugin.js"
|
||||
);
|
||||
const { createLoopPlugin } = await import(
|
||||
"../src/plugins/control/LoopPlugin.js"
|
||||
);
|
||||
|
||||
for (const factory of [
|
||||
createDotNotationPlugin,
|
||||
createArrayIndexPlugin,
|
||||
createCaseTransformPlugin,
|
||||
createRegexPlugin,
|
||||
createStringSplitPlugin,
|
||||
createCounterPlugin,
|
||||
createDateTimePlugin,
|
||||
createUuidPlugin,
|
||||
createConditionalPlugin,
|
||||
createLoopPlugin,
|
||||
]) {
|
||||
expect(typeof factory).toBe("function");
|
||||
}
|
||||
});
|
||||
|
||||
it("imports all utility functions", { timeout: 30000 }, async () => {
|
||||
const escapeMod = await import("../src/utils/escape.js");
|
||||
const format = await import("../src/utils/format.js");
|
||||
const nested = await import("../src/utils/nested-value.js");
|
||||
|
||||
expect(typeof escapeMod.escapeRegex).toBe("function");
|
||||
expect(typeof escapeMod.isEscaped).toBe("function");
|
||||
expect(typeof escapeMod.unescapeTemplate).toBe("function");
|
||||
expect(typeof format.pad).toBe("function");
|
||||
expect(typeof format.formatDate).toBe("function");
|
||||
expect(typeof format.generateUuid).toBe("function");
|
||||
expect(typeof format.generateNanoid).toBe("function");
|
||||
expect(typeof nested.getNestedValue).toBe("function");
|
||||
expect(typeof nested.hasNestedPath).toBe("function");
|
||||
expect(typeof nested.setNestedValue).toBe("function");
|
||||
});
|
||||
|
||||
it("SKIP_PLUGIN is a symbol", { timeout: 30000 }, async () => {
|
||||
const { SKIP_PLUGIN } = await import("../src/types/index.js");
|
||||
expect(typeof SKIP_PLUGIN).toBe("symbol");
|
||||
});
|
||||
|
||||
it("PluginPriority enum has correct ordering", {
|
||||
timeout: 30000,
|
||||
}, async () => {
|
||||
const { PluginPriority } = await import("../src/types/index.js");
|
||||
expect(PluginPriority.MINIMAL).toBeLessThan(PluginPriority.LOW);
|
||||
expect(PluginPriority.LOW).toBeLessThan(PluginPriority.MEDIUM);
|
||||
expect(PluginPriority.MEDIUM).toBeLessThan(PluginPriority.HIGH);
|
||||
expect(PluginPriority.HIGH).toBeLessThan(PluginPriority.CRITICAL);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user