Skip to content

Commit 1382dc5

Browse files
committed
Add two test to cover empty string and speciale characters
1 parent a21fb5e commit 1382dc5

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,3 @@ function assertFunction(currentOutput,targetOutput)
1717
`expect ${currentOutput} to equal ${targetOutput}`
1818
);
1919
}
20-
assertFunction(countChar("Ahmaaa hmaaa",'a'),6);
21-
assertFunction(countChar("Ahmaaa hmaaa",'m'),2 );
22-
assertFunction(countChar("Ahmaaa hmaaa",'b'),0);
23-
assertFunction(countChar("Ahmaaa hmaaa",'A'),1);
24-
assertFunction(countChar("",'A'),0);

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,16 @@ test("should return 2 occurrence of m characters",()=>{
4040
const char = "m";
4141
const count = countChar(str, char);
4242
expect(count).toEqual(2);
43-
})
43+
})
44+
test("should return occurrence of any characters in empty string",()=>{
45+
const str = "";
46+
const char = "@";
47+
const count = countChar(str, char);
48+
expect(count).toEqual(0);
49+
})
50+
test("should return 1 occurrence of @ characters in empty string",()=>{
51+
const str = "[email protected]";
52+
const char = "@";
53+
const count = countChar(str, char);
54+
expect(count).toEqual(1);
55+
})

0 commit comments

Comments
 (0)