pokerogue/src/utils.test.ts
Greenlamp2 bac6c22973
ESLint - The Essential Linter and Formatter for JavaScript and TypeScript (#1224)
* eslint config + packages

* updated eslint config

* fix the issue eslint adding ;;;; at interfaces

* first round with eslint --fix .

* removed config for unused export

* Revert "first round with eslint --fix ."

This reverts commit 77a88e0895.

* removed config for camelCase

* for real this time, first round of eslint --fix .

* halfway to manual eslint fix

* eslint done

* added "how to setup" the hook to eslint --fix each new file before commit (if wanted)

* removed eslintrc config file duplicat

* fix human error + ignore build folder + merge overrides

* added curly brace style + eslint

* applied double quote linter rule

* added lefthook

* test precommit

* test precommit

* test precommit

* test precommit

* test precommit

* test precommit

* test precommit

* github action to run eslint

* added node_modules to ignore eslint

* different action for typescript

* no need for different glob (default src)

* node 20

* node 20

* removed no longer needed install file

* remove hooks part from README

* eslint fixes

---------

Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt>
2024-05-23 11:03:10 -04:00

45 lines
1.2 KiB
TypeScript

import { expect, describe, it } from "vitest";
import { randomString, padInt } from "./utils";
import Phaser from "phaser";
describe("utils", () => {
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");
});
});
});