tests: Basic USER_CHANGES backend tests

This commit is contained in:
Richard Hansen 2021-12-12 03:46:58 -05:00
parent 2cae414473
commit dbacc73c36
2 changed files with 118 additions and 0 deletions

View file

@ -184,3 +184,18 @@ exports.handshake = async (socket, padId) => {
logger.debug('received CLIENT_VARS message');
return msg;
};
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
/**
* Generates a random string.
*
* @param {number} [len] - The desired length of the generated string.
* @param {string} [charset] - Characters to pick from.
* @returns {string}
*/
exports.randomString = (len = 10, charset = `${alphabet}${alphabet.toUpperCase()}0123456789`) => {
let ret = '';
while (ret.length < len) ret += charset[Math.floor(Math.random() * charset.length)];
return ret;
};