I have the following method:
generateKey: () => {
let key =
Math.random()
.toString(36)
.substring(2, 15) +
Math.random()
.toString(36)
.substring(2, 15);
return key;
}
This method generates a random character string and I wish to unit test it.
After searching how to unit test randomness I've come across the following answers but not a concrete application:
How may I test randomness in this specific case?
Testing the length of the string and its content is simple enough, but testing that values were truly generated randomly seems impossible.
Aucun commentaire:
Enregistrer un commentaire