1 import randomIntFromInterval from './randomIntFromInterval';
3 describe('randomIntFromInterval()', () => {
4 it('should be able to return min', () => {
5 jest.spyOn(Math, 'random').mockReturnValue(0);
9 const result = randomIntFromInterval(min, max);
11 expect(result).toBe(min);
14 it('should be able to return max', () => {
15 jest.spyOn(Math, 'random').mockReturnValue(
16 // Math.random does not output 1
22 const result = randomIntFromInterval(min, max);
24 expect(result).toBe(max);
27 it('should return an evenish distribution', () => {
28 jest.spyOn(Math, 'random').mockReturnValue(0.5);
32 const result = randomIntFromInterval(min, max);
34 expect(result).toBe(51);