Skip to content

Commit bd5993b

Browse files
committed
commit
1 parent 860057a commit bd5993b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sprint-3/2-practice-tdd/count.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// implement a function countChar that counts the number of times a character occurs in a string
12
const countChar = require("./count");
23
// Given a string `str` and a single character `char` to search for,
34
// When the countChar function is called with these inputs,
@@ -9,6 +10,19 @@ test("should count occurrences of a character", () => {
910

1011
// Scenario: Multiple Occurrences
1112
// Given the input string `str`,
13+
// And a character `char` that occurs one or more times in `str` (e.g., 'a' in 'aaaaa'),
14+
// When the function is called with these inputs,
15+
// Then it should correctly count occurrences of `char`.
16+
17+
test("should count multiple occurrences of a character", () => {
18+
const str = "aaaaa";
19+
const char = "a";
20+
const count = countChar(str, char);
21+
expect(count).toEqual(5);
22+
});
23+
24+
// Scenario: No Occurrences
25+
// Given the input string `str`,
1226
// And a character `char` that does not exist within `str`.
1327
// When the function is called with these inputs,
1428
// Then it should return 0, indicating that no occurrences of `char` were found.

0 commit comments

Comments
 (0)