Skip to content

Commit 3361ac3

Browse files
committed
added test
1 parent f802832 commit 3361ac3

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,26 @@ test("should return 0 when the character does not occur in the string", () => {
2828
const count = countChar(str, char);
2929
expect(count).toEqual(0);
3030
});
31+
// Single occurrence
32+
test("should count a single occurrence of a character", () => {
33+
const str = "hello";
34+
const char = "e";
35+
const count = countChar(str, char);
36+
expect(count).toEqual(1);
37+
});
38+
39+
// Empty string
40+
test("should return 0 for an empty string", () => {
41+
const str = "";
42+
const char = "a";
43+
const count = countChar(str, char);
44+
expect(count).toEqual(0);
45+
});
46+
47+
// Case sensitivity
48+
test("should treat uppercase and lowercase letters as different", () => {
49+
const str = "AaAa";
50+
const char = "a";
51+
const count = countChar(str, char);
52+
expect(count).toEqual(2);
53+
});

0 commit comments

Comments
 (0)