68 lines
2 KiB
JavaScript
68 lines
2 KiB
JavaScript
import { expect } from "@esm-bundle/chai";
|
|
import { SkillTreeFactory } from "../../src/factories/SkillTreeFactory.js";
|
|
|
|
describe("System: Skill Tree Factory", () => {
|
|
let factory;
|
|
let mockTemplates;
|
|
let mockSkills;
|
|
let mockClassConfig;
|
|
|
|
beforeEach(() => {
|
|
// 1. Setup Mock Data
|
|
mockTemplates = {
|
|
TEMPLATE_STANDARD_30: {
|
|
nodes: {
|
|
ROOT_NODE: {
|
|
tier: 1,
|
|
type: "SLOT_STAT_PRIMARY",
|
|
children: ["CHILD_NODE"],
|
|
},
|
|
CHILD_NODE: { tier: 1, type: "SLOT_SKILL_ACTIVE_1", children: [] },
|
|
},
|
|
},
|
|
};
|
|
|
|
mockSkills = {
|
|
SKILL_FIREBALL: { id: "SKILL_FIREBALL", name: "Fireball", damage: 10 },
|
|
};
|
|
|
|
mockClassConfig = {
|
|
id: "TEST_CLASS",
|
|
skillTreeData: {
|
|
primary_stat: "attack",
|
|
secondary_stat: "defense",
|
|
active_skills: ["SKILL_FIREBALL"],
|
|
passive_skills: ["PASSIVE_BURNING"],
|
|
},
|
|
};
|
|
|
|
// 2. Initialize Factory
|
|
factory = new SkillTreeFactory(mockTemplates, mockSkills);
|
|
});
|
|
|
|
it("CoA 1: Should maintain the topology (structure) of the template", () => {
|
|
const tree = factory.createTree(mockClassConfig);
|
|
|
|
expect(tree.nodes).to.have.property("ROOT_NODE");
|
|
expect(tree.nodes).to.have.property("CHILD_NODE");
|
|
expect(tree.nodes["ROOT_NODE"].children).to.include("CHILD_NODE");
|
|
});
|
|
|
|
it("CoA 2: Should inject Primary Stats based on Class Config", () => {
|
|
const tree = factory.createTree(mockClassConfig);
|
|
const rootNode = tree.nodes["ROOT_NODE"];
|
|
|
|
expect(rootNode.type).to.equal("STAT_BOOST");
|
|
expect(rootNode.data.stat).to.equal("attack"); // Injected from config
|
|
expect(rootNode.data.value).to.equal(2); // Tier 1 * 2
|
|
});
|
|
|
|
it("CoA 3: Should inject Active Skills based on Class Config", () => {
|
|
const tree = factory.createTree(mockClassConfig);
|
|
const childNode = tree.nodes["CHILD_NODE"];
|
|
|
|
expect(childNode.type).to.equal("ACTIVE_SKILL");
|
|
// Should resolve the full skill object from registry
|
|
expect(childNode.data.name).to.equal("Fireball");
|
|
});
|
|
});
|