Pull utils into test.
parent
6d56405bef
commit
06016e550d
|
@ -1,11 +1,46 @@
|
|||
import { expect, describe, it } from "vitest";
|
||||
import { randomString, padInt } from "#app/utils";
|
||||
|
||||
import Phaser from "phaser";
|
||||
import { /*modules to test*/ } from "#app/utils";
|
||||
|
||||
describe("utils", () => {
|
||||
describe("randomString", () => {
|
||||
it("should return a string of the specified length", () => {
|
||||
const str = randomString(10);
|
||||
expect(str.length).toBe(10);
|
||||
});
|
||||
|
||||
//FROM: - src/utils.ts
|
||||
describe.skip("Utils", () => {
|
||||
// Your code here
|
||||
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')
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
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')
|
||||
})
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue