@@ -16,11 +16,38 @@ You must breakdown this problem in order to solve it. Find one test case first a
1616*/
1717const isValidPassword = require ( "./password-validator" ) ;
1818test ( "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- ) ;
19+ // Arrange
20+ const password = "12345" ;
21+ // Act
22+ const result = isValidPassword ( password ) ;
23+ // Assert
24+ expect ( result ) . toEqual ( true ) ;
25+ } ) ;
26+
27+ test ( "returns true for a valid password" , ( ) => {
28+ expect ( isValidPassword ( "Pen5!" ) ) . toBe ( true ) ;
29+ } ) ;
30+
31+ test ( "returns false for a short password" , ( ) => {
32+ expect ( isValidPassword ( "Pen!" ) ) . toBe ( false ) ;
33+ } ) ;
34+
35+ test ( "returns false if there is no uppercase English letter" , ( ) => {
36+ expect ( isValidPassword ( "pen5!" ) ) . toBe ( false ) ;
37+ } ) ;
38+
39+ test ( "returns false if there is no lowercase English letter" , ( ) => {
40+ expect ( isValidPassword ( "PEN5!" ) ) . toBe ( false ) ;
41+ } ) ;
42+
43+ test ( "returns false if there is no number" , ( ) => {
44+ expect ( isValidPassword ( "PENf!" ) ) . toBe ( false ) ;
45+ } ) ;
46+
47+ test ( "returns false if there is no symbol" , ( ) => {
48+ expect ( isValidPassword ( "Pen5a" ) ) . toBe ( false ) ;
49+ } ) ;
50+
51+ test ( "returns false if password is a previous password" , ( ) => {
52+ expect ( isValidPassword ( "HeLlo5." ) ) . toBe ( false ) ;
53+ } ) ;
0 commit comments