mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
* Add array randomizer * Add sequence randomizer * Add barebones readme * Rename randomIntBetween -> randomInteger * Finish couple new randomizer functions * Add basic tsdoc * Add changeset * Downgrade types/node
12 lines
421 B
TypeScript
12 lines
421 B
TypeScript
import { test, expect } from 'vitest';
|
|
import { randomInteger } from './integer.js';
|
|
|
|
test('Returns random number in range', () => {
|
|
const testInts = Array.from(Array(2)).map(() => Math.floor(Math.random() * 1000));
|
|
const min = Math.min(...testInts);
|
|
const max = Math.max(...testInts);
|
|
const output = randomInteger(min, max);
|
|
expect(output).toBeGreaterThanOrEqual(min);
|
|
expect(output).toBeLessThanOrEqual(max);
|
|
});
|