Skip to content

Commit c7bf47b

Browse files
committed
Updated count.test.js to include an additional two scenarios; case sensitive and non-alphanumerics, as per feedback.
1 parent 3f34194 commit c7bf47b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,26 @@ test("should return 0 when character does not occur in string", () => {
2929
const count = countChar(str, char);
3030
expect(count).toEqual(0);
3131
});
32+
// Scenario: Case Sensitivity
33+
// Given the input string `str`,
34+
// And a character `char` that exists in `str` but with different case (e.g., 'A' in 'aAaAa'),
35+
// When the function is called with these inputs,
36+
// Then it should count occurrences of `char` in a case-sensitive manner, meaning 'A' and 'a' are treated as distinct characters.
37+
test("should count characters in a case-sensitive manner", () => {
38+
const str = "aAaAa";
39+
const char = "A";
40+
const count = countChar(str, char);
41+
expect(count).toEqual(2);
42+
});
3243

44+
// Scenario: non-alphanumeric Characters
45+
// Given the input string `str`,
46+
// And a character `char` that is a non-alphanumeric character (e.g., '!' in 'Hello, World!'),
47+
// When the function is called with these inputs,
48+
// Then it should correctly count occurrences of `char`, demonstrating that the function can handle special characters as well.
49+
test("should count non-alphanumeric characters", () => {
50+
const str = "Hello, World!";
51+
const char = "!";
52+
const count = countChar(str, char);
53+
expect(count).toEqual(1);
54+
});

0 commit comments

Comments
 (0)