Skip to content

Commit e918829

Browse files
committed
Test for multiple occurences of a character
1 parent 19a965c commit e918829

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
// implement a function countChar that counts the number of times a character occurs in a string
22
const countChar = require("./count");
3-
// Given a string `str` and a single character `char` to search for,
4-
// When the countChar function is called with these inputs,
5-
// Then it should:
6-
7-
// Scenario: Multiple Occurrences
8-
// Given the input string `str`,
9-
// And a character `char` that occurs one or more times in `str` (e.g., 'a' in 'aaaaa'),
10-
// When the function is called with these inputs,
11-
// Then it should correctly count occurrences of `char`.
123

4+
// Scenario 1: Multiple Occurrences
135
test("should count multiple occurrences of a character", () => {
14-
const str = "aaaaa";
15-
const char = "a";
16-
const count = countChar(str, char);
17-
expect(count).toEqual(5);
6+
expect(countChar("aaaaa", "a")).toEqual(5);
7+
expect(countChar("sea saw", "s")).toEqual(2);
8+
expect(countChar("Arrested Development", "d")).toEqual(2);
9+
expect(countChar("* Star * TV *", "*")).toEqual(3);
1810
});
1911

2012
// Scenario: No Occurrences

0 commit comments

Comments
 (0)