1 import range from './range';
3 describe('range()', () => {
4 it('defaults to creating a specific array if no arguments are provided', () => {
5 expect(range()).toEqual([0]);
8 it('returns an empty array if end is before start', () => {
9 expect(range(10, 2)).toEqual([]);
12 it('returns an empty array if end is same as start', () => {
13 expect(range(2, 2)).toEqual([]);
16 // Here closed is the mathematical definition
17 it('has a closed start', () => {
19 const result = range(start, 2);
20 expect(result[0]).toEqual(start);
23 // Here open is the mathematical definition
24 it('has an open end', () => {
26 const result = range(0, end);
27 expect(result[result.length - 1]).toBeLessThan(end);
30 it('returns range with correct step', () => {
31 expect(range(-4, 5, 2)).toEqual([-4, -2, 0, 2, 4]);
32 expect(range(0, 2, 0.5)).toEqual([0, 0.5, 1, 1.5]);