Skip to content

Commit c8ec84e

Browse files
committed
Added multiple tests for the code.
1 parent b15db6b commit c8ec84e

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎practice-tdd/count.test.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,38 @@ test("should count 0 with no occurrences of a character", () => {
2929
const count = countChar(str, char);
3030
expect(count).toEqual(0);
3131
});
32+
33+
test("should count 0 with no empty string", () => {
34+
const str = "";
35+
const char = "b";
36+
const count = countChar(str, char);
37+
expect(count).toEqual(0);
38+
});
39+
40+
test("should count multiple occurrences of a character in random string", () => {
41+
const str = "accababaade";
42+
const char = "a";
43+
const count = countChar(str, char);
44+
expect(count).toEqual(5);
45+
});
46+
47+
test("should count multiple occurrences of a character in string with empty spaces", () => {
48+
const str = "aa a aa";
49+
const char = "a";
50+
const count = countChar(str, char);
51+
expect(count).toEqual(5);
52+
});
53+
54+
test("should count multiple occurrences of a character in string ignoring upper case", () => {
55+
const str = "aaAaaa";
56+
const char = "a";
57+
const count = countChar(str, char);
58+
expect(count).toEqual(5);
59+
});
60+
61+
test("should count multiple occurrences of a character in string ignoring lower case", () => {
62+
const str = "aAAaAAA";
63+
const char = "A";
64+
const count = countChar(str, char);
65+
expect(count).toEqual(5);
66+
});

0 commit comments

Comments
 (0)