Add jsdoc and unit tests for util functions

This commit is contained in:
2024-12-02 14:10:59 +01:00
parent 618fbe0102
commit e8b91bae4f
4 changed files with 192 additions and 11 deletions
+17
View File
@@ -0,0 +1,17 @@
import { describe, expect, it } from 'bun:test';
import { randomInt } from './random.ts';
describe('random utils', () => {
it('randomInt', () => {
const from = -2;
const to = 6;
for (let i = 0; i < 20; i++) {
const number = randomInt(from, to);
expect(number).toBeNumber();
expect(number).toBeFinite();
expect(number).toBeInteger();
expect(number).toBeGreaterThanOrEqual(from);
expect(number).toBeLessThan(to);
}
});
});