|
1 | 1 | const { NumberRange } = require('.');
|
2 | 2 |
|
3 | 3 | describe('NumberRange', () => {
|
4 |
| - it('should have a min and a max', () => { |
5 |
| - const min = 10; |
6 |
| - const max = 20; |
| 4 | + const min = 10; |
| 5 | + const max = 20; |
7 | 6 |
|
| 7 | + it('should have a min and a max', () => { |
8 | 8 | const range = new NumberRange(min, max);
|
9 | 9 |
|
10 | 10 | expect(range.min).toEqual(min);
|
11 | 11 | expect(range.max).toEqual(max);
|
12 | 12 | });
|
| 13 | + |
| 14 | + describe('contains', () => { |
| 15 | + it('should return true if a number falls inside of the specified range', () => { |
| 16 | + const range = new NumberRange(min, max); |
| 17 | + expect(range.contains(15)).toEqual(true); |
| 18 | + }); |
| 19 | + |
| 20 | + it('should return false if a number falls outside of the specified range', () => { |
| 21 | + const range = new NumberRange(min, max); |
| 22 | + expect(range.contains(9)).toEqual(false); |
| 23 | + expect(range.contains(21)).toEqual(false); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should contain the lower end of the range', () => { |
| 27 | + const range = new NumberRange(min, max); |
| 28 | + expect(range.contains(min)).toEqual(true); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should contain the upper end of the range', () => { |
| 32 | + const range = new NumberRange(min, max); |
| 33 | + expect(range.contains(max)).toEqual(true); |
| 34 | + }); |
| 35 | + }); |
13 | 36 | });
|
0 commit comments