File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,24 @@ 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+
26+ test ( "returns 0 if the character is not in the string" , ( ) => {
27+ const str = "bread" ;
28+ const char = "z" ;
29+ const count = countChar ( str , char ) ;
30+ expect ( count ) . toBe ( 0 ) ;
31+ } ) ;
32+
33+ test ( "counts a character that appears once" , ( ) => {
34+ const str = "bread" ;
35+ const char = "d" ;
36+ const count = countChar ( str , char ) ;
37+ expect ( count ) . toBe ( 1 ) ;
38+ } ) ;
39+
40+ test ( "counts how many times a character appears" , ( ) => {
41+ const str = "breadboard" ;
42+ const char = "b" ;
43+ const count = countChar ( str , char ) ;
44+ expect ( count ) . toBe ( 2 ) ;
45+ } ) ;
You can’t perform that action at this time.
0 commit comments