Add basic tests for all non DOM/Window calls

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
This commit is contained in:
2025-03-10 10:49:35 +09:00
parent 233fb6a235
commit 31d71afe47
5 changed files with 164 additions and 8 deletions

View File

@@ -19,10 +19,11 @@ import {
}); */
describe("randomIdF", () => {
it('Should create a 10 character long random id', () => {
it('Should create a 10 or 11 character long random id', () => {
let rand_id = randomIdF();
expect(rand_id).lengthOf(11);
expect(rand_id).match(/^[a-z0-9]{11}$/);
expect(rand_id.length).toBeGreaterThanOrEqual(10);
expect(rand_id.length).toBeLessThanOrEqual(11);
expect(rand_id).match(/^[a-z0-9]{10,11}$/);
});
});