Skip to content

Commit 9bc1c34

Browse files
committed
Add test to verify countChar returns 1 when the character appears once
1 parent 93d9cb6 commit 9bc1c34

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,17 @@ test("should return 0 occurence of a character", () => {
2727
const char = "z";
2828
const count = countChar(str, char);
2929
expect(count).toEqual(0);
30-
})
30+
});
31+
32+
// Scenario: One occurrence
33+
// Given an input string `str`,
34+
// And a character `char` that occurs once within `str` (e.g., 'a' in 'boat'),
35+
// When the function is called with these inputs,
36+
// Then it should correctly return the count of `char` (e.g., 'a' appears once in 'boat').
37+
38+
test("should return 1 occurence of a character", () => {
39+
const str = "boat";
40+
const char = "a";
41+
const count = countChar(str, char);
42+
expect(count).toEqual(1);
43+
});

0 commit comments

Comments
 (0)