File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ describe("creditCardValidator", () => {
77 } ) ;
88
99 test ( "should return false if the card number is not digit only" , ( ) => {
10- expect ( creditCardValidator ( "1234-5678-9012-345a " ) ) . toBe ( false ) ;
10+ expect ( creditCardValidator ( "1234-5678-abcd-3456 " ) ) . toBe ( false ) ;
1111 expect ( creditCardValidator ( "1234 5678 9012 3456" ) ) . toBe ( true ) ;
1212 } ) ;
1313
@@ -26,4 +26,16 @@ describe("creditCardValidator", () => {
2626 expect ( creditCardValidator ( "1111 1111 1111 1111" ) ) . toBe ( false ) ;
2727 expect ( creditCardValidator ( "1234 5678 9012 3456" ) ) . toBe ( true ) ;
2828 } ) ;
29+
30+ // test for less than 16 digits
31+ test ( "should return false for a card number with less than 16 digits" , ( ) => {
32+ expect ( creditCardValidator ( "123456789012345" ) ) . toBe ( false ) ;
33+ expect ( creditCardValidator ( "1234-5678-9012-345" ) ) . toBe ( false ) ;
34+ } ) ;
35+
36+ // test for more than 16 digits
37+ test ( "should return false for a card number with more than 16 digits" , ( ) => {
38+ expect ( creditCardValidator ( "12345678901234567" ) ) . toBe ( false ) ;
39+ expect ( creditCardValidator ( "1234-5678-9012-34567" ) ) . toBe ( false ) ;
40+ } ) ;
2941} ) ;
You can’t perform that action at this time.
0 commit comments