Files
30-seconds-of-code/test/randomIntArrayInRange/randomIntArrayInRange.test.js
Angelos Chalaris 4f7da1be9b Test migration to jest by hand
Apparently using regular expressions is way easier.
2018-06-18 15:15:56 +03:00

20 lines
800 B
JavaScript

const expect = require('expect');
const randomIntArrayInRange = require('./randomIntArrayInRange.js');
test('randomIntArrayInRange is a Function', () => {
expect(randomIntArrayInRange).toBeInstanceOf(Function);
});
const lowerLimit = Math.floor(Math.random() * 20);
const upperLimit = Math.floor(lowerLimit + Math.random() * 10);
const arr = randomIntArrayInRange(lowerLimit,upperLimit, 10);
test('The returned array contains only integers', () => {
expect(arr.every(x => typeof x === 'number')).toBeTruthy();
});
t.equal(arr.length, 10, 'The returned array has the proper length');
test('The returned array\'s values lie between provided lowerLimit and upperLimit (both inclusive).', () => {
expect(arr.every(x => (x >= lowerLimit) && (x <= upperLimit))).toBeTruthy();
});