Skip to content

Commit ee6b85c

Browse files
author
Ogbemi mene
committed
count.test
1 parent 2abaae2 commit ee6b85c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,23 @@ test("should count multiple occurrences of a character", () => {
2222
// And a character `char` that does not exist within `str`.
2323
// When the function is called with these inputs,
2424
// Then it should return 0, indicating that no occurrences of `char` were found.
25+
26+
test("should return 0 if the character does not exist in the string", () => {
27+
const str = "hello";
28+
const char = "z";
29+
const count = countChar(str, char);
30+
expect(count).toEqual(0);
31+
});
32+
33+
// Scenario: Boundary Case - Empty String
34+
// Given an empty input string `str`,
35+
// And any character `char`,
36+
// When the function is called with these inputs,
37+
// Then it should safely return 0.
38+
39+
test("should return 0 when checking an empty string", () => {
40+
const str = "";
41+
const char = "a";
42+
const count = countChar(str, char);
43+
expect(count).toEqual(0);
44+
});

0 commit comments

Comments
 (0)