mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-04-20 04:17:50 -04:00
* Extract Mode enum out of UI and into its own file Reduces circular imports from 909 to 773 * Move around utility files Reduces cyclical dependencies from 773 to 765 * Remove starterColors and bypassLogin from battle-scene Reduces cyclical dependencies from 765 to 623 * Fix test runner error * Update import for bypassLogin in test * Update mocks for utils in tests * Fix broken tests * Update selectWithTera override * Update path for utils in ab-attr.ts * Update path for utils in ability-class.ts * Fix utils import path in healer.test.ts
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { expect, describe, it, beforeAll } from "vitest";
|
|
import { randomString, padInt } from "#app/utils/common";
|
|
|
|
import Phaser from "phaser";
|
|
|
|
describe("utils", () => {
|
|
beforeAll(() => {
|
|
new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
describe("randomString", () => {
|
|
it("should return a string of the specified length", () => {
|
|
const str = randomString(10);
|
|
expect(str.length).toBe(10);
|
|
});
|
|
|
|
it("should work with seed", () => {
|
|
const state = Phaser.Math.RND.state();
|
|
const str1 = randomString(10, true);
|
|
Phaser.Math.RND.state(state);
|
|
const str2 = randomString(10, true);
|
|
|
|
expect(str1).toBe(str2);
|
|
});
|
|
});
|
|
|
|
describe("padInt", () => {
|
|
it("should return a string", () => {
|
|
const result = padInt(1, 10);
|
|
expect(typeof result).toBe("string");
|
|
});
|
|
|
|
it("should return a padded result with default padWith", () => {
|
|
const result = padInt(1, 3);
|
|
expect(result).toBe("001");
|
|
});
|
|
|
|
it("should return a padded result using a custom padWith", () => {
|
|
const result = padInt(1, 10, "yes");
|
|
expect(result).toBe("yesyesyes1");
|
|
});
|
|
|
|
it("should return inputted value when zero length is entered", () => {
|
|
const result = padInt(1, 0);
|
|
expect(result).toBe("1");
|
|
});
|
|
});
|
|
});
|