Note that these are very basic tests and just a start to learn vitest. There are no tests for DOM/Window because I do not know how to do those tests the best way with some headless brower testing suit or which to use
31 lines
707 B
JavaScript
31 lines
707 B
JavaScript
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", () => {
|
|
it('Should create a 10 or 11 character long random id', () => {
|
|
let rand_id = randomIdF();
|
|
expect(rand_id.length).toBeGreaterThanOrEqual(10);
|
|
expect(rand_id.length).toBeLessThanOrEqual(11);
|
|
expect(rand_id).match(/^[a-z0-9]{10,11}$/);
|
|
});
|
|
});
|
|
|
|
// __END__
|