Making Test Suites
We have improved the validation functions validateUsername and validatePassword adding the following rules for the username and password respectively:
- The username should be between 3 and 20 characters in length and it can only contain alphanumeric characters.
- The password should be at least 8 characters long and it should contain a combination of lower and uppercase letters along with at least one number or symbol;
Your task is to:
- Organize the test cases present in
validation.jsTest Script, into appropriate describe blocks. - Write test cases to test case code in
auth.js. Make sure to enclose the test cases in properdescribeblocks;
Following are the test cases you have to write in the __test__/auth.js file:
Test ID: 1
- Title: Hash a valid password;
- Precondition: The hashPassword function is available;
- Test Steps:
- Pass the string 'examplePassword123' to the hashPassword function;
- Expected Result: The function should return a string that is different from the input password;
Test ID: 2
- Title: Hash an empty password;
- Precondition: The hashPassword function is available;
- Test Steps:
- Pass an empty string '' to the hashPassword function;
- Expected Result: The function should return a non-empty string;
Test ID: 3
- Title: Compare a valid password with its correct hash;
- Precondition: The comparePassword and hashPassword functions are available;
- Test Steps:
- Hash the string 'examplePassword123' using the hashPassword function;
- Pass the original password 'examplePassword123' and the generated hash to the comparePassword function;
- Expected Result: The function should return true, indicating the password matches the hash;
Test ID: 4
- Title: Compare a valid password with an incorrect hash;
- Precondition: The comparePassword and hashPassword functions are available;
- Test Steps:
- Hash the string 'examplePassword123' using the hashPassword function;
- Pass a different password 'wrongPassword456' and the generated hash to the comparePassword function;
- Expected Result: The function should return false, indicating the password does not match the hash;
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 8
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Genial!
Completion tasa mejorada a 3.85
Making Test Suites
Desliza para mostrar el menú
We have improved the validation functions validateUsername and validatePassword adding the following rules for the username and password respectively:
- The username should be between 3 and 20 characters in length and it can only contain alphanumeric characters.
- The password should be at least 8 characters long and it should contain a combination of lower and uppercase letters along with at least one number or symbol;
Your task is to:
- Organize the test cases present in
validation.jsTest Script, into appropriate describe blocks. - Write test cases to test case code in
auth.js. Make sure to enclose the test cases in properdescribeblocks;
Following are the test cases you have to write in the __test__/auth.js file:
Test ID: 1
- Title: Hash a valid password;
- Precondition: The hashPassword function is available;
- Test Steps:
- Pass the string 'examplePassword123' to the hashPassword function;
- Expected Result: The function should return a string that is different from the input password;
Test ID: 2
- Title: Hash an empty password;
- Precondition: The hashPassword function is available;
- Test Steps:
- Pass an empty string '' to the hashPassword function;
- Expected Result: The function should return a non-empty string;
Test ID: 3
- Title: Compare a valid password with its correct hash;
- Precondition: The comparePassword and hashPassword functions are available;
- Test Steps:
- Hash the string 'examplePassword123' using the hashPassword function;
- Pass the original password 'examplePassword123' and the generated hash to the comparePassword function;
- Expected Result: The function should return true, indicating the password matches the hash;
Test ID: 4
- Title: Compare a valid password with an incorrect hash;
- Precondition: The comparePassword and hashPassword functions are available;
- Test Steps:
- Hash the string 'examplePassword123' using the hashPassword function;
- Pass a different password 'wrongPassword456' and the generated hash to the comparePassword function;
- Expected Result: The function should return false, indicating the password does not match the hash;
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 8