@@ -10,11 +10,41 @@ const countChar = require("./count");
1010// When the function is called with these inputs,
1111// Then it should correctly count occurrences of `char`.
1212
13- test ( "should count multiple occurrences of a character" , ( ) => {
13+ /* test("should count multiple occurrences of a character", () => {
1414 const str = "aaaaa";
1515 const char = "a";
1616 const count = countChar(str, char);
1717 expect(count).toEqual(5);
18+ });*/
19+
20+ describe ( "countChar" , ( ) => {
21+ test ( "counts repeated characters in a simple string" , ( ) => {
22+ expect ( countChar ( "aaaaa" , "a" ) ) . toEqual ( 5 ) ;
23+ } ) ;
24+
25+ test ( "counts characters in a mixed string" , ( ) => {
26+ expect ( countChar ( "absankama" , "a" ) ) . toEqual ( 4 ) ;
27+ } ) ;
28+
29+ test ( "counts characters including spaces" , ( ) => {
30+ expect ( countChar ( "ab san kama" , "a" ) ) . toEqual ( 4 ) ;
31+ } ) ;
32+
33+ test ( "counts characters in string with symbols" , ( ) => {
34+ expect ( countChar ( "a-+&£$%?/|b san kama" , "a" ) ) . toEqual ( 4 ) ;
35+ } ) ;
36+
37+ test ( "returns 0 when character is not found" , ( ) => {
38+ expect ( countChar ( "-+&£$%?/|b sn km" , "a" ) ) . toEqual ( 0 ) ;
39+ } ) ;
40+
41+ test ( "returns 0 for empty string" , ( ) => {
42+ expect ( countChar ( "" , "a" ) ) . toEqual ( 0 ) ;
43+ } ) ;
44+
45+ test ( "is case sensitive" , ( ) => {
46+ expect ( countChar ( "AaAa" , "a" ) ) . toEqual ( 2 ) ;
47+ } ) ;
1848} ) ;
1949
2050// Scenario: No Occurrences
0 commit comments