|
| 1 | +const { minimum } = require('../lib/minimum'); |
| 2 | + |
| 3 | +describe('minimum', () => { |
| 4 | + it('should return the minimum of all parameters, given that all parameters evaluate to numbers', () => { |
| 5 | + const result = minimum(1, 5, -7, 15, 10); |
| 6 | + expect(result).toBe(-7); |
| 7 | + }); |
| 8 | + |
| 9 | + it('should throw an error when no parameters are provided', () => { |
| 10 | + expect(minimum).toThrow(); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should throw an error when at least one parameter does not evaluate to a number', () => { |
| 14 | + expect(() => minimum('yo')).toThrow(); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should throw an error when at least one parameter evaluates to a number larger than Number.MAX_SAFE_INTEGER', () => { |
| 18 | + expect(() => minimum(Number.MAX_SAFE_INTEGER + 1)).toThrow(); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should throw an error when at least one parameter evaluates to a number smaller than Number.MIN_SAFE_INTEGER', () => { |
| 22 | + expect(() => minimum(Number.MIN_SAFE_INTEGER - 1)).toThrow(); |
| 23 | + }); |
| 24 | +}); |
0 commit comments