Skip to content

Commit a61f9b1

Browse files
committed
updated pr template
1 parent 31f50ad commit a61f9b1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@ test("should count multiple occurrences of a character", () => {
1616
const count = countChar(str, char);
1717
expect(count).toEqual(5);
1818
});
19+
test("should return 0 when the character is not found", () => {
20+
const str = "hello";
21+
const char = "z";
22+
const count = countChar(str, char);
23+
expect(count).toEqual(0);
24+
});
25+
26+
// Scenario: Case Sensitivity
27+
// It should be case-sensitive, meaning 'A' != 'a'.
28+
test("should be case-sensitive when counting characters", () => {
29+
const str = "Banana";
30+
expect(countChar(str, "a")).toEqual(3);
31+
expect(countChar(str, "A")).toEqual(0);
32+
});
33+
34+
// Scenario: Empty String
35+
// It should return 0 when the input string is empty.
36+
test("should return 0 when the input string is empty", () => {
37+
const str = "";
38+
const char = "a";
39+
const count = countChar(str, char);
40+
expect(count).toEqual(0);
41+
});
42+
43+
// Scenario: Special Characters
44+
// It should correctly count spaces and punctuation.
45+
test("should count special characters like spaces or punctuation", () => {
46+
expect(countChar("a b a b", " ")).toEqual(2);
47+
expect(countChar("wow!!!", "!")).toEqual(3);
48+
});
1949

2050
// Scenario: No Occurrences
2151
// Given the input string str,

0 commit comments

Comments
 (0)