Skip to content

Commit 47c3136

Browse files
committed
add nore test case to count.test.js
1 parent 3289b60 commit 47c3136

File tree

4 files changed

+4461
-3
lines changed

4 files changed

+4461
-3
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,27 @@ test("should count multiple occurrences of a character", () => {
1717
expect(count).toEqual(5);
1818
});
1919

20+
test("should count multiple occurrences of a character", () => {
21+
const str = "bbb";
22+
const char = "b";
23+
const count = countChar(str, char);
24+
expect(count).toEqual(3);
25+
});
26+
27+
test("should count mutiple of character 'coco can have coconut'", () => {
28+
const str = "coco can have coconut";
29+
const char = "c";
30+
const count = countChar(str, char);
31+
expect(count).toEqual(5);
32+
});
33+
34+
test("should count multiple occurrences of a character 'a' in 'I have an apple'", () => {
35+
const str = "I have an apple";
36+
const char = "a";
37+
const count = countChar(str, char);
38+
expect(count).toEqual(3);
39+
});
40+
2041
// Scenario: No Occurrences
2142
// Given the input string str,
2243
// And a character char that does not exist within the case-sensitive str,
@@ -29,3 +50,17 @@ test("should return 0 when the character does not exist in the string", () => {
2950
const count = countChar(str, char);
3051
expect(count).toEqual(0);
3152
});
53+
54+
test("should return 0 when the character does not exist in the string", () => {
55+
const str = "hello";
56+
const char = "z";
57+
const count = countChar(str, char);
58+
expect(count).toEqual(0);
59+
});
60+
61+
test("should return 0 when the 'c' does not exist in string 'I dont have an apple'", () => {
62+
const str = "I dont have an apple";
63+
const char = "c";
64+
const count = countChar(str, char);
65+
expect(count).toEqual(0);
66+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "2-practice-tdd",
3+
"version": "1.0.0",
4+
"description": "In this section you'll practice this key skill of building up your program test first.",
5+
"main": "count.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"type": "commonjs"
13+
}

0 commit comments

Comments
 (0)