add unit test for util function padInt (#175)
Co-authored-by: Viet Nguyen <vietnguyen@Viets-MacBook-Air.local>pull/549/merge
parent
80b6001c77
commit
f22c25d376
|
@ -1,5 +1,5 @@
|
||||||
import { expect, describe, it } from "vitest";
|
import { expect, describe, it } from "vitest";
|
||||||
import { randomString } from "./utils";
|
import { randomString, padInt } from "./utils";
|
||||||
|
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
|
|
||||||
|
@ -19,4 +19,26 @@ describe("utils", () => {
|
||||||
expect(str1).toBe(str2);
|
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