2025-03-07 19:01:58 +09:00
|
|
|
import { describe, it, expect } from "vitest";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
// generateId,
|
|
|
|
|
randomIdF,
|
|
|
|
|
} from '../src/utils/UniqIdGenerators.mjs';
|
|
|
|
|
|
|
|
|
|
// window. is not defined in headless mode
|
|
|
|
|
// TODO: fix
|
|
|
|
|
/* describe("generateId", () => {
|
|
|
|
|
it('Should create a random id in defined length', () => {
|
|
|
|
|
let len_list = [
|
|
|
|
|
1, 12, 24, 32, 64
|
|
|
|
|
];
|
|
|
|
|
for (let len of len_list) {
|
|
|
|
|
expect(generateId(len)).lengthOf(len);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}); */
|
|
|
|
|
|
|
|
|
|
describe("randomIdF", () => {
|
2025-03-10 10:49:35 +09:00
|
|
|
it('Should create a 10 or 11 character long random id', () => {
|
2025-03-07 19:01:58 +09:00
|
|
|
let rand_id = randomIdF();
|
2025-03-10 10:49:35 +09:00
|
|
|
expect(rand_id.length).toBeGreaterThanOrEqual(10);
|
|
|
|
|
expect(rand_id.length).toBeLessThanOrEqual(11);
|
|
|
|
|
expect(rand_id).match(/^[a-z0-9]{10,11}$/);
|
2025-03-07 19:01:58 +09:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// __END__
|