@@ -15,12 +15,30 @@ 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" , ( ) => {
19- // Arrange
20- const password = "12345" ;
21- // Act
22- const result = isValidPassword ( password ) ;
23- // Assert
24- expect ( result ) . toEqual ( true ) ;
25- }
26- ) ;
18+ describe ( "passwordValidator" , ( ) => {
19+ const password = "123Ab*" ;
20+
21+ test ( "returns true for passwords with at least 5 characters" , ( ) => {
22+ expect ( isValidPassword ( password ) ) . toBe ( true ) ;
23+ } ) ;
24+
25+ test ( "return true for passwords with at least one uppercase letter" , ( ) => {
26+ expect ( isValidPassword ( password ) ) . toBe ( true ) ;
27+ } ) ;
28+
29+ test ( "return true for passwords with at least one lowercase letter" , ( ) => {
30+ expect ( isValidPassword ( password ) ) . toBe ( true ) ;
31+ } ) ;
32+
33+ test ( "return true for passwords with at least one number" , ( ) => {
34+ expect ( isValidPassword ( password ) ) . toBe ( true ) ;
35+ } ) ;
36+
37+ test ( "return true for passwords with at least one non-alphanumeric symbol" , ( ) => {
38+ expect ( isValidPassword ( password ) ) . toBe ( true ) ;
39+ } ) ;
40+
41+ test ( "return true for passwords that are not in the previous passwords array" , ( ) => {
42+ expect ( isValidPassword ( password ) ) . toBe ( true ) ;
43+ } ) ;
44+ } ) ;
0 commit comments