@@ -16,34 +16,35 @@ You must breakdown this problem in order to solve it. Find one test case first a
1616*/
1717import { isValidPassword } from "./password-validator.js" ;
1818
19- test ( "password should have at least 5 characters and meets all rules" , ( ) => {
20- const password = "Abc1!" ;
21- const result = isValidPassword ( password ) ;
22- expect ( result ) . toEqual ( true ) ;
19+ const previousPasswords = [ "password" , "12345" , "qwerty" ] ;
20+
21+ test ( "should accept a password that meets all rules" , ( ) => {
22+ expect ( isValidPassword ( "Abc1!" ) ) . toEqual ( true ) ;
2323} ) ;
2424
25- test ( "should rejects password shorter than 5 characters" , ( ) => {
25+ test ( "should reject a password shorter than 5 characters" , ( ) => {
26+ // only length fails: has upper, lower, digit, symbol
2627 expect ( isValidPassword ( "Ab1!" ) ) . toEqual ( false ) ;
2728} ) ;
2829
29- test ( "should rejects password without uppercase" , ( ) => {
30+ test ( "should reject a password without an uppercase letter " , ( ) => {
3031 expect ( isValidPassword ( "abc1!" ) ) . toEqual ( false ) ;
3132} ) ;
3233
33- test ( "should rejects password without lowercase" , ( ) => {
34+ test ( "should reject a password without a lowercase letter " , ( ) => {
3435 expect ( isValidPassword ( "ABC1!" ) ) . toEqual ( false ) ;
3536} ) ;
3637
37- test ( "should rejects password without number " , ( ) => {
38+ test ( "should reject a password without a digit " , ( ) => {
3839 expect ( isValidPassword ( "Abcde!" ) ) . toEqual ( false ) ;
3940} ) ;
4041
41- test ( "should rejects password without symbol" , ( ) => {
42+ test ( "should reject a password without a required symbol" , ( ) => {
4243 expect ( isValidPassword ( "Abc12" ) ) . toEqual ( false ) ;
4344} ) ;
4445
45- test ( "should rejects previous password" , ( ) => {
46- expect ( isValidPassword ( "password" ) ) . toEqual ( false ) ;
46+ test ( "should reject a previous password" , ( ) => {
47+ expect ( isValidPassword ( "password" , previousPasswords ) ) . toEqual ( false ) ;
4748} ) ;
4849
4950test ( "should reject a password listed in the previousPasswords argument" , ( ) => {
0 commit comments