aether-shards/test/core/GameLoop/initialization.test.js
Matthew Mone ac0f3cc396 Enhance testing and integration of inventory and character management systems
Add comprehensive tests for the InventoryManager and InventoryContainer to validate item management functionalities. Implement integration tests for the CharacterSheet component, ensuring proper interaction with the inventory system. Update the Explorer class to support new inventory features and maintain backward compatibility. Refactor related components for improved clarity and performance.
2025-12-27 16:54:03 -08:00

55 lines
1.6 KiB
JavaScript

import { expect } from "@esm-bundle/chai";
import * as THREE from "three";
import { GameLoop } from "../../../src/core/GameLoop.js";
import {
createGameLoopSetup,
cleanupGameLoop,
createRunData,
} from "./helpers.js";
describe("Core: GameLoop - Initialization", function () {
this.timeout(30000);
let gameLoop;
let container;
beforeEach(() => {
const setup = createGameLoopSetup();
gameLoop = setup.gameLoop;
container = setup.container;
});
afterEach(() => {
cleanupGameLoop(gameLoop, container);
});
it("CoA 1: init() should setup Three.js scene, camera, and renderer", () => {
gameLoop.init(container);
expect(gameLoop.scene).to.be.instanceOf(THREE.Scene);
expect(gameLoop.camera).to.be.instanceOf(THREE.PerspectiveCamera);
expect(gameLoop.renderer).to.be.instanceOf(THREE.WebGLRenderer);
// Verify renderer is attached to DOM
expect(container.querySelector("canvas")).to.exist;
});
it("CoA 2: startLevel() should initialize grid, visuals, and generate world", async () => {
gameLoop.init(container);
const runData = createRunData();
await gameLoop.startLevel(runData, { startAnimation: false });
// Grid should be populated
expect(gameLoop.grid).to.exist;
// Check center of map (likely not empty for RuinGen) or at least check valid bounds
expect(gameLoop.grid.size.x).to.be.greaterThan(0);
// VoxelManager should be initialized
expect(gameLoop.voxelManager).to.exist;
// Should have visual meshes
expect(gameLoop.scene.children.length).to.be.greaterThan(0);
});
});