@@ -22,3 +22,34 @@ test("should count multiple occurrences of a character", () => {
2222// And a character char that does not exist within the case-sensitive str,
2323// When the function is called with these inputs,
2424// Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str.
25+ test ( "should return 0 if no occurrences of a character" , ( ) => {
26+ const str = "bbbbbb" ;
27+ const char = "a" ;
28+ const count = countChar ( str , char ) ;
29+ expect ( count ) . toEqual ( 0 ) ;
30+ } ) ;
31+
32+ // Scenario: Single Occurrence
33+ test ( "should return 1 for a single occurrence of a character" , ( ) => {
34+ const str = "hello" ;
35+ const char = "e" ;
36+ const count = countChar ( str , char ) ;
37+ expect ( count ) . toEqual ( 1 ) ;
38+ } ) ;
39+
40+ // Scenario: Case Sensitivity
41+ test ( "should be case sensitive when counting characters" , ( ) => {
42+ const str = "Hello World" ;
43+ const char = "h" ;
44+ const count = countChar ( str , char ) ;
45+ expect ( count ) . toEqual ( 0 ) ;
46+ } ) ;
47+
48+ // Scenario: Empty String
49+ test ( "should return 0 when the input string is empty" , ( ) => {
50+ const str = "" ;
51+ const char = "a" ;
52+ const count = countChar ( str , char ) ;
53+ expect ( count ) . toEqual ( 0 ) ;
54+ } ) ;
55+
0 commit comments