Skip to content

Commit 01cb978

Browse files
committed
Add unit test to verify countChar returns 0 when given an empty string
1 parent 9bc1c34 commit 01cb978

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ test("should return 1 occurence of a character", () => {
4141
const count = countChar(str, char);
4242
expect(count).toEqual(1);
4343
});
44+
45+
test("should return 0 occurrence of character in an empty string", () => {
46+
const str = "";
47+
const char = "b";
48+
const count = countChar(str, char);
49+
expect(count).toEqual(0);
50+
});
51+

0 commit comments

Comments
 (0)