Skip to content

Commit fe47102

Browse files
committed
added several edge cases to pass the tests
1 parent c1afcc2 commit fe47102

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,59 @@ test("should count no occurrences of a character", () => {
1212
const count = countChar(str, char);
1313
expect(count).toEqual(0);
1414
});
15+
16+
test("should count no occurrences of a character", () => {
17+
const str = "";
18+
const char = "a";
19+
const count = countChar(str, char);
20+
expect(count).toEqual(0);
21+
});
22+
23+
test("should count minnimum occurrence of a character", () => {
24+
const str = "a";
25+
const char = "a";
26+
const count = countChar(str, char);
27+
expect(count).toEqual(1);
28+
});
29+
30+
test("should count no occurrences of a character", () => {
31+
const str = "b";
32+
const char = "a";
33+
const count = countChar(str, char);
34+
expect(count).toEqual(0);
35+
});
36+
37+
test("should count occurrence of special character", () => {
38+
const str = "!!!!";
39+
const char = "!";
40+
const count = countChar(str, char);
41+
expect(count).toEqual(4);
42+
});
43+
44+
test("should count character at the beggining", () => {
45+
const str = "cow";
46+
const char = "c";
47+
const count = countChar(str, char);
48+
expect(count).toEqual(1);
49+
});
50+
51+
test("should count character at the end", () => {
52+
const str = "apple";
53+
const char = "e";
54+
const count = countChar(str, char);
55+
expect(count).toEqual(1);
56+
});
57+
58+
test("should count lowercase character", () => {
59+
const str = "Apple";
60+
const char = "a";
61+
const count = countChar(str, char);
62+
expect(count).toEqual(0);
63+
});
64+
65+
test("should count occurrence of spaces", () => {
66+
const str = "a b c";
67+
const char = " ";
68+
const count = countChar(str, char);
69+
expect(count).toEqual(2);
70+
});

0 commit comments

Comments
 (0)