WheelOfFortune/tests/serverTests.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

const { DefaultNames,NameIndex,
getRandomName,getRandomValue,shuffleArray } = require('../server');
const puzzles = require('../puzzles.json');
const names = require('../assignedNames.json');
const assert = require('assert');
function resetGlobals() {
//initialize variables
NameIndex = 0;
}
function testNames() {
for (let i of DefaultNames){
console.log(getRandomName());
}
}
beforeEach(function () {
//resetGlobals();
});
afterEach(function () {
//resetGlobals();
});
/*
function testNames() {
let results = [];
for (let i of DefaultNames) {
let name = getRandomName();
results.push(name);
}
if (results.) {}
}
*/
describe('getRandomName',()=>{
it('should be of type string',()=>{
const result = getRandomName();
assert(typeof result == 'string','this should be a string')
})
it('should never have an undefined value',()=>{
let results = [];
for (let i of DefaultNames) {
let name = getRandomName();
results.push(name);
}
console.log(results);
console.log(results.filter((i) => i === undefined).length);
assert(results.filter((i) => i === undefined).length < 1)
})
})