Skip to content

Commit 050f3c5

Browse files
committed
count.jest
1 parent 3372770 commit 050f3c5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,31 @@ const countChar = require("./count");
44
// When the countChar function is called with these inputs,
55
// Then it should:
66

7+
78
// Scenario: Multiple Occurrences
89
// Given the input string `str`,
910
// And a character `char` that occurs one or more times in `str` (e.g., 'a' in 'aaaaa'),
1011
// When the function is called with these inputs,
1112
// Then it should correctly count occurrences of `char`.
1213

14+
1315
test("should count multiple occurrences of a character", () => {
1416
const str = "aaaaa";
1517
const char = "a";
1618
const count = countChar(str, char);
1719
expect(count).toEqual(5);
1820
});
1921

22+
2023
// Scenario: No Occurrences
2124
// Given the input string `str`,
2225
// And a character `char` that does not exist within `str`.
2326
// When the function is called with these inputs,
2427
// Then it should return 0, indicating that no occurrences of `char` were found.
28+
29+
test("should return 0 when the character is not found", () => {
30+
const str = "hello";
31+
const char = "z";
32+
const count = countChar(str, char);
33+
expect(count).toEqual(0);
34+
});

0 commit comments

Comments
 (0)