@@ -17,6 +17,27 @@ test("should count multiple occurrences of a character", () => {
1717 expect ( count ) . toEqual ( 5 ) ;
1818} ) ;
1919
20+ test ( "should count multiple occurrences of a character" , ( ) => {
21+ const str = "bbb" ;
22+ const char = "b" ;
23+ const count = countChar ( str , char ) ;
24+ expect ( count ) . toEqual ( 3 ) ;
25+ } ) ;
26+
27+ test ( "should count mutiple of character 'coco can have coconut'" , ( ) => {
28+ const str = "coco can have coconut" ;
29+ const char = "c" ;
30+ const count = countChar ( str , char ) ;
31+ expect ( count ) . toEqual ( 5 ) ;
32+ } ) ;
33+
34+ test ( "should count multiple occurrences of a character 'a' in 'I have an apple'" , ( ) => {
35+ const str = "I have an apple" ;
36+ const char = "a" ;
37+ const count = countChar ( str , char ) ;
38+ expect ( count ) . toEqual ( 3 ) ;
39+ } ) ;
40+
2041// Scenario: No Occurrences
2142// Given the input string str,
2243// And a character char that does not exist within the case-sensitive str,
@@ -29,3 +50,17 @@ test("should return 0 when the character does not exist in the string", () => {
2950 const count = countChar ( str , char ) ;
3051 expect ( count ) . toEqual ( 0 ) ;
3152} ) ;
53+
54+ test ( "should return 0 when the character does not exist in the string" , ( ) => {
55+ const str = "hello" ;
56+ const char = "z" ;
57+ const count = countChar ( str , char ) ;
58+ expect ( count ) . toEqual ( 0 ) ;
59+ } ) ;
60+
61+ test ( "should return 0 when the 'c' does not exist in string 'I dont have an apple'" , ( ) => {
62+ const str = "I dont have an apple" ;
63+ const char = "c" ;
64+ const count = countChar ( str , char ) ;
65+ expect ( count ) . toEqual ( 0 ) ;
66+ } ) ;
0 commit comments