Test cleanup and fixes [q-r]

This commit is contained in:
Angelos Chalaris
2018-06-18 18:13:18 +03:00
parent 072728dad2
commit 9c22d92c34
23 changed files with 147 additions and 202 deletions

View File

@ -1,21 +1,18 @@
const expect = require('expect');
const randomIntArrayInRange = require('./randomIntArrayInRange.js');
test('randomIntArrayInRange is a Function', () => {
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', () => {
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();
});
test('The returned array has the proper length', () => {
expect(arr.length, 10).toBe()
test('The returned array has the proper length', () => {
expect(arr.length).toBe(10);
});
test('The returned array\'s values lie between provided lowerLimit and upperLimit (both inclusive).', () => {
test('The returned array\'s values lie between provided lowerLimit and upperLimit (both inclusive).', () => {
expect(arr.every(x => (x >= lowerLimit) && (x <= upperLimit))).toBeTruthy();
});