Skip to content

Commit 0f0bd35

Browse files
committed
Add test cases for non-alphabetical and case sensitivity
1 parent 73a1500 commit 0f0bd35

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,27 @@ test("should count non-contiguous occurrences of a character", () => {
4040
const count = countChar(str, char);
4141
expect(count).toEqual(6);
4242
});
43+
44+
// Scenario: Same character in upper and lower case.
45+
// Given the input string 'str'
46+
// And a character 'char' that apears in both lower case and upper case.
47+
// When the function is called with these inputs,
48+
// Then it should only count when the cases match
49+
test("should be case sensitive", () => {
50+
const str = "Hello, how are you";
51+
const char = "H";
52+
const count = countChar(str, char);
53+
expect(count).toEqual(1);
54+
});
55+
56+
// Scenario: Non-alphabetical chars in the string.
57+
// Given the input string 'str'
58+
// And a character 'char' that is not in the alphabet
59+
// When the function is called with these inputs,
60+
// Then it should match as usual
61+
test("should match non-alphabetical chars", () => {
62+
const str = "Incredible news! We've joined Code Your Future!";
63+
const char = "!";
64+
const count = countChar(str, char);
65+
expect(count).toEqual(2);
66+
});

0 commit comments

Comments
 (0)