[Dev] Add imports, Handle kebab-case fileName argument in test boilerplate script (#4072)
* add imports, handle kebab-case fileName argument * fix spacing
This commit is contained in:
parent
8df7422e8f
commit
401568609b
|
@ -20,12 +20,15 @@ const type = args[0]; // "move" or "ability"
|
|||
let fileName = args[1]; // The file name
|
||||
|
||||
if (!type || !fileName) {
|
||||
console.error('Please provide both a type ("move", "ability", or "item") and a file name.');
|
||||
console.error('Please provide a type ("move", "ability", or "item") and a file name.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Convert fileName from to snake_case if camelCase is given
|
||||
fileName = fileName.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
|
||||
// Convert fileName from kebab-case or camelCase to snake_case
|
||||
fileName = fileName
|
||||
.replace(/-+/g, '_') // Convert kebab-case (dashes) to underscores
|
||||
.replace(/([a-z])([A-Z])/g, '$1_$2') // Convert camelCase to snake_case
|
||||
.toLowerCase(); // Ensure all lowercase
|
||||
|
||||
// Format the description for the test case
|
||||
const formattedName = fileName
|
||||
|
@ -64,10 +67,12 @@ if (fs.existsSync(filePath)) {
|
|||
|
||||
// Define the content template
|
||||
const content = `import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import { SPLASH_ONLY } from "#test/utils/testUtils";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, it } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest";
|
||||
|
||||
describe("${description}", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
|
@ -87,14 +92,15 @@ describe("${description}", () => {
|
|||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.moveset([Moves.SPLASH])
|
||||
.battleType("single")
|
||||
.enemyAbility(Abilities.BALL_FETCH)
|
||||
.enemyMoveset(SPLASH_ONLY);
|
||||
});
|
||||
|
||||
it("test case", async () => {
|
||||
// await game.classicMode.startBattle();
|
||||
// game.move.select();
|
||||
// await game.classicMode.startBattle([Species.MAGIKARP]);
|
||||
// game.move.select(Moves.SPLASH);
|
||||
}, TIMEOUT);
|
||||
});
|
||||
`;
|
||||
|
|
Loading…
Reference in New Issue