pokerogue/test/test-utils/helpers/settings-helper.ts
Bertie690 9815c5eebf
[Test] Revamped MockConsoleLog with color support (#6218)
* Added mock console and fixed up many many things

* Cleaned up handling of colors and such

* Added minor comment

* Fix Focus Punch test

* Fix typo

* Remove redundant comment

* Update vitest.setup.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Added color map inside new folder

* Made constants not object bc i was told to

* Update src/constants/colors.ts

* Removed all moves init check

* Removed import

* Fixed up some stuff + added aquamarine color to settings helper

* Added logging for test end

* Removed intentionally failing test

* Fixed console log to use inheritance to not override vitest's wrapping

* Added a custom Vitest reporter to not log the test name every 2 lines

* Moved coloration to a hook to prevent misplacing things

* Fixed import issue by copypasting vitest soure

* Removed intentionally failing test

look i need to check that `test:silent` works on github ok

* Added REUSE annotations to copied parts of source

* Fixed import issue

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-09-07 09:18:47 -05:00

57 lines
1.7 KiB
TypeScript

import { SETTINGS_COLOR } from "#app/constants/colors";
import { BattleStyle } from "#enums/battle-style";
import { ExpGainsSpeed } from "#enums/exp-gains-speed";
import { PlayerGender } from "#enums/player-gender";
import { GameManagerHelper } from "#test/test-utils/helpers/game-manager-helper";
import chalk from "chalk";
/**
* Helper to handle settings for tests
*/
export class SettingsHelper extends GameManagerHelper {
private _battleStyle: BattleStyle = BattleStyle.SET;
get battleStyle(): BattleStyle {
return this._battleStyle;
}
/**
* Change the battle style to Switch or Set mode (tests default to {@linkcode BattleStyle.SET})
* @param mode {@linkcode BattleStyle.SWITCH} or {@linkcode BattleStyle.SET}
*/
set battleStyle(mode: BattleStyle.SWITCH | BattleStyle.SET) {
this._battleStyle = mode;
}
/**
* Disable/Enable type hints settings
* @param enable true to enabled, false to disabled
*/
typeHints(enable: boolean): void {
this.game.scene.typeHints = enable;
this.log(`Type Hints ${enable ? "enabled" : "disabled"}`);
}
/**
* Change the player gender
* @param gender the {@linkcode PlayerGender} to set
*/
playerGender(gender: PlayerGender) {
this.game.scene.gameData.gender = gender;
this.log(`Gender set to: ${PlayerGender[gender]} (=${gender})`);
}
/**
* Change the exp gains speed
* @param speed the {@linkcode ExpGainsSpeed} to set
*/
expGainsSpeed(speed: ExpGainsSpeed) {
this.game.scene.expGainsSpeed = speed;
this.log(`Exp Gains Speed set to: ${ExpGainsSpeed[speed]} (=${speed})`);
}
private log(...params: any[]) {
console.log(chalk.hex(SETTINGS_COLOR)(...params));
}
}