File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -4,21 +4,31 @@ const countChar = require("./count");
44// When the countChar function is called with these inputs,
55// Then it should:
66
7+
78// Scenario: Multiple Occurrences
89// Given the input string `str`,
910// And a character `char` that occurs one or more times in `str` (e.g., 'a' in 'aaaaa'),
1011// When the function is called with these inputs,
1112// Then it should correctly count occurrences of `char`.
1213
14+
1315test ( "should count multiple occurrences of a character" , ( ) => {
1416 const str = "aaaaa" ;
1517 const char = "a" ;
1618 const count = countChar ( str , char ) ;
1719 expect ( count ) . toEqual ( 5 ) ;
1820} ) ;
1921
22+
2023// Scenario: No Occurrences
2124// Given the input string `str`,
2225// And a character `char` that does not exist within `str`.
2326// When the function is called with these inputs,
2427// Then it should return 0, indicating that no occurrences of `char` were found.
28+
29+ test ( "should return 0 when the character is not found" , ( ) => {
30+ const str = "hello" ;
31+ const char = "z" ;
32+ const count = countChar ( str , char ) ;
33+ expect ( count ) . toEqual ( 0 ) ;
34+ } ) ;
You can’t perform that action at this time.
0 commit comments