|
| 1 | +const { maximum } = require('../lib/maximum'); |
| 2 | + |
| 3 | +describe('maximum', () => { |
| 4 | + it('should return the maximum of all parameters, given that all parameters evaluate to numbers', () => { |
| 5 | + const result = maximum(1, 5, -7, 15, 10); |
| 6 | + expect(result).toBe(15); |
| 7 | + }); |
| 8 | + |
| 9 | + it('should throw an error when no parameters are provided', () => { |
| 10 | + expect(maximum).toThrow(); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should throw an error when at least one parameter does not evaluate to a number', () => { |
| 14 | + expect(() => maximum('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(() => maximum(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(() => maximum(Number.MIN_SAFE_INTEGER - 1)).toThrow(); |
| 23 | + }); |
| 24 | +}); |
0 commit comments