aether-shards/test/units/Enemy.test.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

import { expect } from "@esm-bundle/chai";
import { Enemy } from "../../src/units/Enemy.js";
describe("Unit: Enemy Class Logic", () => {
it("CoA 1: Should initialize with default values when definition is minimal", () => {
const def = { model: "goblin.glb" };
const enemy = new Enemy("e1", "Goblin", def);
expect(enemy.id).to.equal("e1");
expect(enemy.name).to.equal("Goblin");
expect(enemy.type).to.equal("ENEMY");
// Defaults defined in class constructor
expect(enemy.archetypeId).to.equal("BRUISER");
expect(enemy.aggroRange).to.equal(8);
expect(enemy.voxelModelID).to.equal("goblin.glb");
});
it("CoA 2: Should hydrate stats from definition", () => {
const def = {
stats: {
health: 200,
attack: 15,
speed: 5,
},
};
const enemy = new Enemy("e2", "Boss", def);
expect(enemy.baseStats.health).to.equal(200);
expect(enemy.currentHealth).to.equal(200); // Should auto-fill current HP
expect(enemy.maxHealth).to.equal(200);
expect(enemy.baseStats.attack).to.equal(15);
expect(enemy.baseStats.speed).to.equal(5);
});
it("CoA 3: Should set specific AI and Reward properties", () => {
const def = {
ai_archetype: "KITER",
aggro_range: 12,
xp_value: 50,
loot_table: "LOOT_RARE",
};
const enemy = new Enemy("e3", "Sniper", def);
expect(enemy.archetypeId).to.equal("KITER");
expect(enemy.aggroRange).to.equal(12);
expect(enemy.xpValue).to.equal(50);
expect(enemy.lootTableId).to.equal("LOOT_RARE");
});
});