@@ -22,6 +22,29 @@ test ("should return 0 when the character does not exist in the string", () => {
2222 const count = countChar ( str , char ) ;
2323 expect ( count ) . toEqual ( 0 ) ;
2424} ) ;
25+ test ( "should return 0 when the input string is empty" , ( ) => {
26+ const str = "" ;
27+ const char = "a" ;
28+ const count = countChar ( str , char ) ;
29+ expect ( count ) . toEqual ( 0 ) ;
30+ } ) ;
31+ test ( "should return 0 when the input character is an empty string" , ( ) => {
32+ const str = "test" ;
33+ const char = "" ;
34+ const count = countChar ( str , char ) ;
35+ expect ( count ) . toEqual ( 0 ) ;
36+ } ) ;
37+ test ( "should return 0 when both the input string and character are empty" , ( ) => {
38+ const str = "" ;
39+ const char = "" ;
40+ const count = countChar ( str , char ) ;
41+ expect ( count ) . toEqual ( 0 ) ;
42+ } ) ;
43+ // Scenario: Empty String
44+ // Given an empty input string `str`,
45+ // And any character `char` (e.g., 'a'),
46+ // When the function is called with these inputs,
47+ // Then it should return 0, indicating that no occurrences of `char` were found in the empty string.
2548
2649// Scenario: No Occurrences
2750// Given the input string `str`,
0 commit comments