* feat(lib): add more tests to lib package Add more tests to the lib package to make it more robust overall. Additionally, tidy any methods that can be modified without changing behaviour and tighten types where possible. * fix(lib): update missed imports * fix: revert stylistic changes * Update getSchedule.test.ts --------- Co-authored-by: Omar López <zomars@me.com>
31 lines
766 B
TypeScript
31 lines
766 B
TypeScript
import { randomString } from "./random";
|
|
|
|
describe("Random util tests", () => {
|
|
describe("fn: randomString", () => {
|
|
it("should return a random string of a given length", () => {
|
|
const length = 10;
|
|
|
|
const result = randomString(length);
|
|
|
|
expect(result).toHaveLength(length);
|
|
});
|
|
|
|
it("should return a random string of a default length", () => {
|
|
const length = 12;
|
|
|
|
const result = randomString();
|
|
|
|
expect(result).toHaveLength(length);
|
|
});
|
|
|
|
it("should return a random string of a given length using alphanumeric characters", () => {
|
|
const length = 10;
|
|
|
|
const result = randomString(length);
|
|
|
|
expect(result).toMatch(/^[a-zA-Z0-9]+$/);
|
|
expect(result).toHaveLength(length);
|
|
});
|
|
});
|
|
});
|