Use a random number instead of hard coded in test

This commit is contained in:
Gabe Kangas 2023-01-22 20:43:01 -08:00
parent 96f2015fbf
commit 748219d93e
No known key found for this signature in database
GPG key ID: 4345B2060657F330
2 changed files with 5 additions and 5 deletions

View file

@ -92,7 +92,7 @@ const appearanceValues = {
const streamOutputVariants = {
videoBitrate: randomNumber() * 100,
framerate: 42,
cpuUsageLevel: 2,
cpuUsageLevel: randomNumber(4, 0),
scaledHeight: randomNumber() * 100,
scaledWidth: randomNumber() * 100,
};

View file

@ -2,14 +2,14 @@ const crypto = require('crypto');
const Random = require('crypto-random');
//returns a random number in range of [1 - max]
function randomNumber(max = 5) {
return Random.range(1, max);
function randomNumber(max = 5, min = 1) {
return Random.range(0, max);
}
//returns a random hex string
function randomString(length = 20) {
const bytesCount = Math.ceil(length / 2);
return crypto.randomBytes(bytesCount).toString('hex').substring(0, length);
const bytesCount = Math.ceil(length / 2);
return crypto.randomBytes(bytesCount).toString('hex').substring(0, length);
}
module.exports.randomNumber = randomNumber;