|
| 1 | +import test from 'ava' |
| 2 | +import { range } from '../src' |
| 3 | + |
| 4 | +test('creates an array of numbers from start up to end', t => { |
| 5 | + const expected = [1, 2, 3, 4] |
| 6 | + const actual = range(1, 5); |
| 7 | + t.deepEqual(actual, expected) |
| 8 | +}) |
| 9 | + |
| 10 | +test('creates an array of numbers starting from zero given an implicit end', t => { |
| 11 | + const expected = [0, 1, 2, 3] |
| 12 | + const actual = range(4); |
| 13 | + t.deepEqual(actual, expected) |
| 14 | +}) |
| 15 | + |
| 16 | +test('creates an array of numbers in given steps', t => { |
| 17 | + const expected = [0, 5, 10, 15] |
| 18 | + const actual = range(0, 20, 5); |
| 19 | + t.deepEqual(actual, expected) |
| 20 | +}) |
| 21 | + |
| 22 | +test('creates an array of negative numbers given a negative step', t => { |
| 23 | + const expected = [0, -1, -2, -3] |
| 24 | + const actual = range(0, -4, -1); |
| 25 | + t.deepEqual(actual, expected) |
| 26 | +}) |
| 27 | + |
| 28 | +test('creates an empty array with no parameters given', t => { |
| 29 | + const expected = [] |
| 30 | + const actual = range(); |
| 31 | + t.deepEqual(actual, expected) |
| 32 | +}) |
0 commit comments