@@ -17,10 +17,33 @@ You must breakdown this problem in order to solve it. Find one test case first a
1717const isValidPassword = require ( "./password-validator" ) ;
1818test ( "password has at least 5 characters" , ( ) => {
1919 // Arrange
20- const password = "12345" ;
21- // Act
22- const result = isValidPassword ( password ) ;
23- // Assert
24- expect ( result ) . toEqual ( true ) ;
20+ const password = "Ha!1" ;
21+ expect ( ( ) => isValidPassword ( password ) ) . toThrow ( ) ;
2522}
26- ) ;
23+ ) ;
24+ test ( "password has at least one uppercase letter(A-Z)" , ( ) => {
25+ const password = "harju!1621" ;
26+
27+
28+ expect ( ( ) => isValidPassword ( password ) ) . toThrow ( ) ;
29+ } ) ;
30+ test ( "password has at least one lowercase letter (a-z)" , ( ) => {
31+ const password = "HARJU!1621" ;
32+ expect ( ( ) => isValidPassword ( password ) ) . toThrow ( ) ;
33+ } ) ;
34+ test ( "password has at least one number (0-9)" , ( ) => {
35+ const password = "Harju!" ;
36+ expect ( ( ) => isValidPassword ( password ) ) . toThrow ( ) ;
37+ } ) ;
38+ test ( "password has at least one special character " , ( ) => {
39+ const password = "Harju1621" ;
40+ expect ( ( ) => isValidPassword ( password ) ) . toThrow ( ) ;
41+ } ) ;
42+ test ( "password not match with previous password" , ( ) => {
43+ const password = "Arun!1621" ;
44+ expect ( ( ) => isValidPassword ( password ) ) . toThrow ( ) ;
45+ } ) ;
46+ test ( "password meet all the condition" , ( ) => {
47+ const password = "Harju!1621" ;
48+ expect ( isValidPassword ( password ) ) . toEqual ( true ) ;
49+ } ) ;
0 commit comments