@@ -14,13 +14,38 @@ To be valid, a password must:
1414
1515You must breakdown this problem in order to solve it. Find one test case first and get that working
1616*/
17+
1718const isValidPassword = require ( "./password-validator" ) ;
19+
1820test ( "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- ) ;
21+ // Arrange
22+ const password = "Abc1!" ;
23+ // Act
24+ const result = isValidPassword ( password ) ;
25+ // Assert
26+ expect ( result ) . toEqual ( true ) ;
27+ } ) ;
28+
29+ test ( "password with less than 5 characters returns false" , ( ) => {
30+ expect ( isValidPassword ( "Ab1!" ) ) . toEqual ( false ) ;
31+ } ) ;
32+
33+ test ( "password without uppercase returns false" , ( ) => {
34+ expect ( isValidPassword ( "abc1!" ) ) . toEqual ( false ) ;
35+ } ) ;
36+
37+ test ( "password without lowercase returns false" , ( ) => {
38+ expect ( isValidPassword ( "ABC1!" ) ) . toEqual ( false ) ;
39+ } ) ;
40+
41+ test ( "password without number returns false" , ( ) => {
42+ expect ( isValidPassword ( "Abcd!" ) ) . toEqual ( false ) ;
43+ } ) ;
44+
45+ test ( "password without special symbol returns false" , ( ) => {
46+ expect ( isValidPassword ( "Abcd1" ) ) . toEqual ( false ) ;
47+ } ) ;
48+
49+ test ( "valid password with all requirements returns true" , ( ) => {
50+ expect ( isValidPassword ( "Abc1!" ) ) . toEqual ( true ) ;
51+ } ) ;
0 commit comments