Files
Mana-Loop/src/lib/game/store-tests/game-constants.test.ts
T
Refactoring Agent d2d28887b1
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m9s
Refactor large files into modular components
- Refactored page.tsx (613→252 lines) with GameOverScreen and LeftPanel extracted
- Refactored StatsTab.tsx (584→92 lines) with section components
- Refactored SkillsTab.tsx (434→54 lines) with sub-components
- Created modular structure for GameContext, LootInventory, and other components
- All extracted components organized into feature directories
2026-05-02 17:35:03 +02:00

116 lines
4.1 KiB
TypeScript

/**
* Tests for Game Constants
*/
import { describe, it, expect } from 'vitest';
import { ELEMENTS, GUARDIANS, SPELLS_DEF, SKILLS_DEF, PRESTIGE_DEF } from '../constants';
describe('Game Constants', () => {
describe('ELEMENTS', () => {
it('should have all base elements', () => {
// Life, blood, wood were removed - we have 7 base elements now
expect(ELEMENTS.fire).toBeDefined();
expect(ELEMENTS.water).toBeDefined();
expect(ELEMENTS.air).toBeDefined();
expect(ELEMENTS.earth).toBeDefined();
expect(ELEMENTS.light).toBeDefined();
expect(ELEMENTS.dark).toBeDefined();
expect(ELEMENTS.death).toBeDefined();
});
it('should have composite elements with recipes', () => {
// blood and wood were removed
expect(ELEMENTS.metal.recipe).toEqual(['fire', 'earth']);
expect(ELEMENTS.sand.recipe).toEqual(['earth', 'water']);
expect(ELEMENTS.lightning.recipe).toEqual(['fire', 'air']);
});
it('should have exotic elements with 3-ingredient recipes', () => {
expect(ELEMENTS.crystal.recipe).toHaveLength(3);
expect(ELEMENTS.stellar.recipe).toHaveLength(3);
expect(ELEMENTS.void.recipe).toHaveLength(3);
});
it('should have utility element transference', () => {
expect(ELEMENTS.transference).toBeDefined();
expect(ELEMENTS.transference.cat).toBe('utility');
});
});
describe('GUARDIANS', () => {
it('should have guardians on expected floors', () => {
// Note: Floor 70 was removed
[10, 20, 30, 40, 50, 60, 80, 90, 100].forEach(floor => {
expect(GUARDIANS[floor]).toBeDefined();
});
});
it('should have increasing HP', () => {
let prevHP = 0;
[10, 20, 30, 40, 50, 60, 80, 90, 100].forEach(floor => {
expect(GUARDIANS[floor].hp).toBeGreaterThan(prevHP);
prevHP = GUARDIANS[floor].hp;
});
});
it('should have increasing pact multipliers', () => {
let prevPact = 1;
[10, 20, 30, 40, 50, 60, 80, 90, 100].forEach(floor => {
expect(GUARDIANS[floor].pact).toBeGreaterThan(prevPact);
prevPact = GUARDIANS[floor].pact;
});
});
});
describe('SPELLS_DEF', () => {
it('should have manaBolt as a basic spell', () => {
expect(SPELLS_DEF.manaBolt).toBeDefined();
expect(SPELLS_DEF.manaBolt.tier).toBe(0);
expect(SPELLS_DEF.manaBolt.cost.type).toBe('raw');
});
it('should have spells for existing base elements', () => {
// Life was removed, death is present
const elements = ['fire', 'water', 'air', 'earth', 'light', 'dark', 'death'];
elements.forEach(elem => {
const hasSpell = Object.values(SPELLS_DEF).some(s => s.elem === elem);
expect(hasSpell).toBe(true);
});
});
it('should have increasing damage for higher tiers', () => {
const tier0Avg = Object.values(SPELLS_DEF).filter(s => s.tier === 0).reduce((a, s) => a + s.dmg, 0);
const tier1Avg = Object.values(SPELLS_DEF).filter(s => s.tier === 1).reduce((a, s) => a + s.dmg, 0);
const tier2Avg = Object.values(SPELLS_DEF).filter(s => s.tier === 2).reduce((a, s) => a + s.dmg, 0);
expect(tier1Avg).toBeGreaterThan(tier0Avg);
expect(tier2Avg).toBeGreaterThan(tier1Avg);
});
});
describe('SKILLS_DEF', () => {
it('should have skills with valid categories', () => {
const validCategories = ['mana', 'study', 'research', 'ascension', 'enchant', 'effectResearch', 'invocation', 'pact', 'fabrication', 'golemancy', 'craft', 'hybrid'];
Object.values(SKILLS_DEF).forEach(skill => {
expect(validCategories).toContain(skill.cat);
});
});
it('should have reasonable study times', () => {
Object.values(SKILLS_DEF).forEach(skill => {
expect(skill.studyTime).toBeGreaterThan(0);
expect(skill.studyTime).toBeLessThanOrEqual(72);
});
});
});
describe('PRESTIGE_DEF', () => {
it('should have prestige upgrades with valid costs', () => {
Object.values(PRESTIGE_DEF).forEach(def => {
expect(def.cost).toBeGreaterThan(0);
expect(def.max).toBeGreaterThan(0);
});
});
});
});