@@ -15,12 +15,42 @@ To be valid, a password must:
1515You must breakdown this problem in order to solve it. Find one test case first and get that working
1616*/
1717const isValidPassword = require ( "./password-validator" ) ;
18- test ( "password has at least 5 characters" , ( ) => {
18+ test ( "Password has at least 5 characters" , ( ) => {
1919 // Arrange
20- const password = "12345 " ;
20+ const password = "Cc#1 " ;
2121 // Act
2222 const result = isValidPassword ( password ) ;
2323 // Assert
24+ expect ( result ) . toEqual ( false ) ;
25+ }
26+ ) ;
27+ test ( "Have at least one English uppercase letter (A-Z)" , ( ) => {
28+ const password = "AaBb5%Cc#11Zz" ;
29+ const result = isValidPassword ( password ) ;
30+ expect ( result ) . toEqual ( true ) ;
31+ }
32+ ) ;
33+ test ( "Have at least one English lowercase letter (a-z)" , ( ) => {
34+ const password = "AaBbCcZ2#z" ;
35+ const result = isValidPassword ( password ) ;
36+ expect ( result ) . toEqual ( true ) ;
37+ }
38+ ) ;
39+ test ( "Have at least one number (0-9)" , ( ) => {
40+ const password = "1Aa0CcZz!Bb9" ;
41+ const result = isValidPassword ( password ) ;
42+ expect ( result ) . toEqual ( true ) ;
43+ }
44+ ) ;
45+ test ( "Have at least one of the following non-alphanumeric symbols:" , ( ) => {
46+ const password = "Aa0Cc!ZzB#b9" ;
47+ const result = isValidPassword ( password ) ;
48+ expect ( result ) . toEqual ( true ) ;
49+ }
50+ ) ;
51+ test ( "Must not be any previous password in the passwords array." , ( ) => {
52+ const password = "Aa0Cc!ZzB#b9" ;
53+ const result = isValidPassword ( password ) ;
2454 expect ( result ) . toEqual ( true ) ;
2555}
2656) ;
0 commit comments